Ruby on Rails
Friday, December 21, 2012
I posted a previous message about overriding initialize... because I was having issues setting some of the parameters. I have a Page model that has:
attr_accessible :url, :title, :doc, :domain
and it's called via:
Page.new(:url => 'http://www.yahoo.com')
Since I'm only passing in the url to new, I needed to set the other parameters. I was trying to do this via an after_initialize callback which wasn't working so tried overriding initialize... still not working.
What I found out was that in my after_initialize, I was referring to title as @title which is why it was not working. I switched it to self.title and it works fine.
My question is - why?
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/-ncNakybQ-cJ.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment