Page 1 of 1
[01:44:04] d08z: hi, lets say i have a Country model and a City model, which belongs_to country... What happens if i do this: c = City.new; c.country_id = 42; <-- does assigning the foreign key will automagically create the c.country association?
[11:34:35] d08z: hi, how can i ensure that my belongs_to association exists in the databas? validates_presence_of does not work (you could put a newly created object plus there is no guarantee the object is still in the database when saving)
[11:40:18] d08z: either im doing something really wrong or i dont understand because i thought it would be a very simple common and task to validate the existence :(
[11:45:06] d08z: ok so what you guys are telling me is "there is no way to validate that an objects exists in the database before saving it"
[11:50:48] d08z: ok lets say i have a Country and a City model, country has_many cities and City belongs_to country
[11:51:28] d08z: how can i validate (IN RAILS) that the associated country (city.country) exists in the database when saving
[11:54:39] d08z: ensures the relation is not null, has an id, is not new and hits the database with model.exists(foreign_key_id) before saving
[15:03:46] d08z: hi, what would be the best way to "return object method value if the method exists else return a default value", something like puts x.blah() || "default" (if x has no "blah" method)
[17:43:24] d08z: i have a file "lib/blah.rb" and inside "blah.rb" there is a "require_relative foo.rb" ... now, to use my lib in my controller i "require_dependency lib/blah". How can i ensure BOTH files are "reloaded" when i update the code in dev mode?
[17:45:08] d08z: tubbo: i dont have to, but, putting it in the autoload_paths does not reload the code on each request
[17:50:39] d08z: tbuehlmann: yes and no, both symbols are loaded and works, the "blah" class is reloaded on each request but NOT the foo class (although loaded the first time)
[17:51:14] d08z: tubbo: the "require_dependency" instruction is in a rails controller, not in the libs
[17:55:06] d08z: lets just rephrase my question: can i work on a lib under /lib without always re-starting the rails server
[17:56:12] d08z: ok i think there might be a language barrier i dont know how to ask my question (which sounded so simple in my head)
[18:03:59] d08z: the problem with asking questions about programming is you always get answers about engineering :(
[18:06:54] d08z: in fact my question is really simple: how can i modify and reload the code of a file that is NOT under /app
[18:08:55] d08z: tubbo: ok let's say i have a file called "foo.rb" that only contains ONE LINE: "require_relative bar.rb"
[18:16:03] d08z: i know i know but i thought that if i require_dependency a file, the whole "graph" is not loaded
[15:31:19] d08z: does anyone know how to get rid of: Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
[14:11:01] d08z: hi, does anyone know how to get rid of the spring warning message to run 'gem pristine --all'? (yes, i did run it and yes, i did go on stackoverflow before asking! :)
[14:14:48] d08z: suchness: ran the small script and typed 'gem pristine --all' and i still have the warning
[14:17:58] d08z: nah i dont mind being "schooled", the only problem is i really dont understand what you mean
[17:11:07] d08z: hi, i would like to know what is the accepted convention as where to put my custom executables/scripts in the ROR directory?
[17:16:33] d08z: tubbo: ok so, my own libs in libs/, my script in bin/ and the 3rd party lib i need for the script in vendor/, am i getting this right?