On 9 December 2012 20:25, Dan Brooking <
dmbro...@gmail.com> wrote:
> One of my modesl looks like this:
>
> class UnprocessedPage < ActiveRecord::Base
> has_one :user
> attr_accessible :url, :user_id
> end
>
> Do I need :user_id? Or is it implied via "has_one :user"?
You should not have a user_id column in the database for a has_one
association. If UnprocessedPage has_one :user then User belongs_to
:unprocessed_page and User should have an unprocessed_page_id column.
Are you sure you do not mean User has_many :unprocessed_pages and
UnprocessedPage belongs_to :user?
Have a look at the Rails Guide on ActiveRecord Associations for more
details and if you have not already done so then work right through a
good rails tutorial such as
railstutorial.org, which is free to use
online, in order to get the basics of Rails.
Colin