On Sep 4, 2013, at 8:17 AM, Dave Castellano wrote:

> But, even the following causes error: undefined method `key=' for 
> #<Question:0x007fcba5972f20>
> 
> before_validation :capitalize_first_words
> 
>    def capitalize_first_words
>      [:question, :correct_ans_1, :correct_ans_2].each do|key|
>          self.key = "x"

maybe

        self.send(":#{key}=", "x")

or:

        self[key] = "x"

Not sure of either. But your instinct is correct, key isn't being evaluated 
before it is passed to the self reference, so you're still looking for a key 
method that isn't there.


>      end
>    end
> 
> key is still not being interpreted  as "question" or  "correct_ans_1", 
> ect...
> Could it be a scope issue?  I am in the Question model.
> 

Walter

> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/1e2a081f66832bf47930d5c31699819f%40ruby-forum.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/BCDF2DBA-8948-428E-95D5-9C9C0D66E73A%40wdstudio.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to