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
When you create a project you can do:
@project = Project.find(params[:id])
@task = Task.create(params[:task])
@project.tasks @task
or something similar. this will automatically out the user id I the
project table for you.
On Jan 30, 6:43 am, Souschef sgalva...@gmail.com wrote:
Here are my
Can you show us the code that is not working?
Make sure you have the relationship specified in your model so Rails
knows it's there. so you should have
class Project ActiveRecord::Base
belongs_to :user
end
so that you can do:
Project.new :user = @user
or
Project.new :user_id = 12
and then
I believe you will have to learn about associations (or relationships
between tables, as another post has already noted). Look into
'belongs_to' and 'has_*' relationships (probably 'has_one' or
'has_many'). That will most likely teach you what you need.
On Jan 26, 7:16 pm, Souschef
Souschef wrote:
I've added a foreign key to a table (specifically, user_Id to my
projects table so I can select 'myprojects') and now when I add a
project, the user_id is not being saved in the projects table. In a
former life, I would update my SQL statements, but this is rails.
Where do I
5 matches
Mail list logo