When I click the Save in /views/parts/new.html, I expect to end up on /
views/parts/show.html, but instead I end up in /views/projects/
index.html, with the wrong [flash] message.
I have:
++++++++++++++++
/models/project.rb
has_many :parts
++++++++++++++++
/models/parts.rb
belongs_to :project
++++++++++++++++
/controllers/parts_controller.rb
def new
@project = Project.find(params[:project_id])
@part = @project.parts.build
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @part }
end
end
def create
@project = Project.find(params[:project_id])
@part = @project.parts.build(params[:concept])
@part.user_id = @current_user
respond_to do |format|
if @concept.save
flash[:notice] = 'You have successfully defined a new part
for this project’
format.html { redirect_to part_path(@part) }
format.xml { render :xml => @part, :status
=> :created, :location => @part }
else
format.html { render :action => “new” }
format.xml { render :xml => @part.errors, :status
=> :unprocessable_entity }
end
end
end
++++++++++++++++
/views/parts/new.html
form_for(@project, @part) do |f|
So, when I click Save in that button, I expect to end up on /views/
parts/show.html, with a nice [flash] reading ‘You have successfully
defined a new part for this project’. Instead, I end up on /views/
projects/index.html, with the [flash] message defined in the update
action in the projects controller.
What’s going on and how can I fix this?
Many thanks,
Steven.