#rubyonrails - Sat 31 Mar 2007 between 12:17 and 12:30

NY Lost Funds



zorglu_RubyPanther: ok you already told me that :)
RubyPanther: do you know the answer to my question ? :)
RubyPantherzorglu_: I don't know if it would blow up or not, but even if it works now, no reason to assume it will work in the next version, etc
zorglu_ok thanks :)
RubyPantherzorglu_: I did, what you're doing is achieved with conditionals
ie, executing only certain parts of the code depending on stuff
zorglu_i understand
JensBI have models: User, Language, and Userlanguage (intermediate). User contains "has_many :languages, through => :userlanguages", Language contains "has_many :users, through => :userlanguages", Userlanguage contains two belongs_to lines. Now how do I populate these tables? Every user should have one mother tongue ("mt" column, boolean, in Userlanguages) and as many additional languages as he wants.
eg. calling "User.find(1).languages" throws an error: uninitialized constant User::Languages
RubyPantherJensB: I would grab the language with UserLanguages.find and then do user.languages << lang or += [ lang ]
shafirewhere can i find a plugin tutorial?
RubyPanthershafire: wiki.rubyonrails.com (.org?)
rellik_why do I have to call #find_by_sql with an exising model? the query I am using returns information not related to any particular model
should I just choose a random model for #find_by_sql?
JensBrellik_, what is your SQL query?
RubyPantherrellik_: why are you using find_by_sql?
rellik_JensB, sec.. I'll paste it
RubyPanthersounds like ActiveRecord::Base.connection.select_all might be better
rellik_RubyPanther, because it's a complicated query and it is much more efficient to do it in SQL
RubyPantherselect or select_all it depends on the db driver which to use
JensBRubyPanther, in the above example, any idea why User#languages does not exist? Did I forget something?
RubyPantherrellik_: yeah, use .connection to grab the connection
rellik_RubyPanther, does that return objects that I can call obj.column_name on?
RubyPantheryou can do MyModel.connection, too, it's the same thing
rellik_RubyPanther, (as if I had use find_by_sql)
RubyPantherrellik_: if you query contains info not related to the model, and you want the model at the same time, that's probably going to take a little work if you want it to be elegant
claudioI have an hard time figuring out the best way to implement "contacts". They are people for people. So I have a "people_contacts" table in has_many :through.
I have problems with "<<" and delete and cascade destroy... anyone with a nice example to feed me?
rellik_RubyPanther, no, I don't care about having access to the model.. I just want the obj.column_name access.. where column_name is from the query, not any partiular model
RubyPantherrellik_: but just using find_by_sql, the data should show up as if it was part of the model, so that's fine as long as you're using it read-only
rellik_RubyPanther, JensB http://pastie.caboo.se/50794
RubyPantherthe select_all result is a hash, so that makes it easy enough
an array of hashes rather
rellik_RubyPanther, looking at it now.. select_all looks like exactly what I wanted
JensBargh
now I have a "HasManyThroughAssociationNotFoundError"
what _exactly_ do I have to do to get User, Userlanguage and Language working together as a has-many-through? and how can I use it then?
RubyPantherJensB: maybe a classname isn't to spec?
JensBI have the agile book here, but it isn't very verbose about this
I don't use any Ruby reserved words if that's what you mean

Page: 5 12 19 26 33 40 47 54 61 68 75 82 

IrcArchive

NY Lost Funds