Displaying 1 result from an estimated 1 matches for "author_with_lookup".
2009 Aug 17
1
Problem with setter override on ActiveRecord
...is
valid).
After search a lot for a solution (and try many other things in vain),
I found this message: http://groups.google.com/group/rubyonrails-talk/browse%5Fthread/thread/4fe057494c6e23e8,
so finally I could had some working code:
class Book < ActiveRecord::Base
belongs_to :author
def author_with_lookup=(author)
author = Author.find_or_initialize_by_name(author) if author.is_a?
String
self.author_without_lookup = author
end
alias_method_chain :author=, :lookup
end
This time, the console was nice to me:
>> book = Book.new(:name => "Alice''s Adventures in Wonderla...