Rails create and new creating different objects
I have a model Project and a model Test. Project has many Tests.
My tests_controller has:
def new
@project = Project.find(params[:project_id])
@test = @project.tests.new
end
def create
@project = Project.find(params[:project_id])
@test = @project.tests.create(test_params)
end
So in my new.html.erb, I present a form, and when submit is pressed,
create is called. I'm confused however because what is apparently
happening is that I am creating one test in new and a whole different test
in create. What is the correct paradigm for what I am trying to achieve?
No comments:
Post a Comment