Issue
I have a trouble with creating custom create method.
I'm using Projects model and projects controller. After new project is added it redirects to that projects show page. Here comes the problem. I have a button to call clone_project method since I need to create new project with the data from selected project and with empty name field. So, I've created route:
resources :projects do
get 'clone/:id', action: 'clone_project', on: :collection
end
and a view page that uses form partial. With this I've manage just to edit existing project since I don't seem to get how to use form with post method like in create action.
Solution
instead render form partial with existing project
you could try something like:
new_project = existing_roject.dup
new_project.title = ""
and then render form with this object
Answered By - Igor Guzak Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.