Re: [Rails] attribute name selected in form

2010-06-23 Thread Lasse Bunk
Or you could make the [] method you mentioned. In your model: def []=(lang, term) self.attributes = { lang => term } end Then you can call it like you wanted: @thesaurus['fr'] = "Bonjour" /Lasse 2010/6/23 Lasse Bunk > Hi, > > I suppose the best way to do this would be to create a row for e

Re: [Rails] attribute name selected in form

2010-06-23 Thread Lasse Bunk
Hi, I suppose the best way to do this would be to create a row for each word having a column for lang and a column for term. If you want to do it the way you describe, you could do it like this: With validation: @thesaurus.update_attributes params[:lang] => term Without validation: @thesaurus.u

[Rails] attribute name selected in form

2010-06-22 Thread Mlle
Hello, I have a form to add terms to a thesaurus table. I have a drop-down list for the user to select the language (fr, en, es,), and then a text box to write a term with a code. I want to set the @thesaurus[whichever language was selected] = term. How can I say @thesaurus['fr'] = term, where '