Displaying 1 result from an estimated 1 matches for "activerrecord".
Did you mean:
activerecord
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
...title
t.integer :author_id
end
create_table :authors do |t|
t.text :name
end
end
def self.down
drop_table :articles
drop_table :authors
end
end
# articles model
class Article < ActiveRecord::Base
belongs_to :author
end
# authors model
class Author < ActiverRecord::Base
has_many :articles
end
WHEN:
>> Article.create(:title => ''one'').author = Author.create(:name => ''Pavel'')
>> Article.create(:title => ''two'').author = Author.find(:first, :conditions => {:name => ''Pav...