1

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.

Community
  • 1
  • 1
Ossie
  • 1,103
  • 2
  • 13
  • 31

1 Answers1

2

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) %>
zishe
  • 10,665
  • 12
  • 64
  • 103
  • 1
    That works I think. My new form is making it crash now but the second code you gave works. clone_miniature_path. Great. Thank you so much. – Ossie Jun 18 '14 at 12:30