This is a nub question. I have a resource Project which has_many Feeds. When I am viewing the list of nested Feeds on the Project page, I have a Delete button to remove that Feed from the Project. It works with this syntax:
<%= link_to 'Delete', [feed.project, feed], :confirm => 'Are you sure?', :method => :delete %>
But that then directs to the page listing all the Feeds, and I instead want it to redirect back to the Project page the user was just at. Is it a matter of changing [feed.project, feed] or is it something else? I don’t quite understand the syntax of link_to well enough yet.
EDIT:
In my feeds_controller.rb, I changed the redirect line to :back
def destroy
project = Project.find(params[:project_id])
@feed = project.feeds.find(params[:id])
@feed.destroy
redirect_to :back
respond_to do |format|
format.html { redirect_to :back }
format.xml { head :ok }
end
end
You must have a look at the controller for this resource. It should be somewhere like
app/controllers/projects_controller, where’s there should be an action nameddestroy. The code that do the redirect must be in there. You’ll have to change the following line:to this