0 wicked var/www % ./script/console Loading development environment.>> r = Recipe.find :firstNameError: undefined method `recipe_type='' for class `Recipe'' from ./script/../config/../config/../app/models/recipe.rb: 101:in `alias_method'' In recipes_controller: alias_method :orig_recipe_type=, :recipe_typedef recipe_type=(t) if t.nil? self.orig_recipe_type = guess_recipe_type self.recipe_type_is_guess = true else self.orig_recipe_type = t self.recipe_type_is_guess = false end end recipe_type is a column in my recipes table. Does this happen because AR uses method_missing to do recipe_type=? Can I get around this? Thanks, --Dean --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/26/07, Dean <dean.brundage-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> recipe_type is a column in my recipes table. Does this happen because > AR uses method_missing to do recipe_type=? Can I get around this?Correct. Use super. http://errtheblog.com/post/20 def recipe_type=(t) if t.nil? super guess_recipe_type self.recipe_type_is_guess = true else super t self.recipe_type_is_guess = false end end -- Chris Wanstrath http://errtheblog.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 26, 1:04 am, "Chris Wanstrath" <c...-G5sj8e7vJc8@public.gmane.org> wrote:> On 2/26/07, Dean <dean.brund...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > recipe_type is a column in my recipes table. Does this happen because > > AR uses method_missing to do recipe_type=? Can I get around this? > > Correct. Use super. > > http://errtheblog.com/post/20 > > def recipe_type=(t) > if t.nil? > super guess_recipe_type > self.recipe_type_is_guess = true > else > super t > self.recipe_type_is_guess = false > end > end > > -- > Chris Wanstrathhttp://errtheblog.comThanks for the reply Chris and the follow up explanation. That explains why alias_method works for my association assignments :-) --Dean --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---