Reputation: 1113
I'm following this answer on how to clone a record.
I can't though workout how to phrase the link and route it.
It is in my @miniature show view so I thought it should be something like
<%= link_to 'clone', :controller => :miniatures_controller, :action => :clone %>
and the route
match 'clone', to: 'miniatures#clone', via: 'get'
but this is clearly wrong. I am using @miniature in place of the above answer's @prescription.
Upvotes: 1
Views: 53
Reputation: 10825
What if you just use clone_path
:
<%= link_to 'clone', clone_path %>
Cause rake routes
shows just clone
route. It works with the same routes.
If you are not satisfied with route and you should pass parameters (like miniature_id
), add member to your resource (probably nested), like:
resources :miniatures do
member do
get 'clone'
end
end
This will be clone_miniature_path
where you should pass @miniature
:
<%= link_to 'clone', clone_miniature_path(@miniature) %>
Upvotes: 2