Here are my models.  I think the issue is how I have the user
associated with the project.  I recently integrated the authlogic
plugin and associated the user to the project table (see below).  I'm
stumped because when I associated 'tasks' to 'projects', the foreign
key for project was inserted into tasks. But for some reason now that
I have 'users' associated with projects, the user_id is not inserted
into the project table on a save when a user is logged in.  Should I
be associating 'projects' to the 'UserSession' instead (model also
included below, but currently empty)?  Or do I need to declare some
sort of logic that saves user_id when a user is actually logged in?
Thanks in advance for input!

--------------------Project model--------------------
class Project < ActiveRecord::Base
  validates_presence_of :name

# allow ordering of tasks by step_number
  has_many :tasks, :dependent => :destroy, :order => 'step_number ASC'
  accepts_nested_attributes_for :tasks, :reject_if => lambda { |a|
a.values.all?(&:blank?) }, :allow_destroy => true

  def task_attributes=(task_attributes)
    task_attributes.each do |attributes|
     tasks.build(attributes)
    end
  end

  # Following statements tie Projects to users
  belongs_to :user

end

--------------------User model--------------------
class User < ActiveRecord::Base
  # following line commented out.  Came from authlogic, but not sure
  # what it means…
  # attr_accessible :username, :email, :password

  # Added following line from railscast demo.  Note:
  # http://github.com/binarylogic/authlogic_example
  # has an optional block for passing other config options, but didn’t
  # go there for now…
  acts_as_authentic

  has_many :projects
end

------------------User Session model---------------
class UserSession < Authlogic::Session::Base
end

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to