I have a routing error that I simply cannot figure out! Its doing my head in, if anyone can suggest a solution that would be hugely appreciated.
I get the error: ROUTING ERROR No route matches {:action=>"create_from_template", :controller=>"projects"}
from the following button:
<p><%= link_to "Create from template", create_from_template_project_path %></p>
In routes.rb I have:
resources :projects do
member do
get 'create_from_template'
end
end
In class ProjectsController I have:
def create_from_template
#@project = Project.find(params[:template_id])
#@project.clone
redirect_to projects_path
end
It also shows up when I do "rake routes"
create_from_template_project GET /projects/:id/create_from_template(.:format) {:action=>"create_from_template", :controller=>"projects"}
Anyone have any idea why it isnt working?
EDIT: Actually maybe I have misunderstood the "member" nested resource routing rules. I wasnt passing in a project. I have changed the button from
to
<p><%= link_to "Create from template", create_from_template_project_path(template_project) %></p>
and now it works. Thanks everyone that helped.