How to define action with simple form for?

Ruby on-RailsRubyRuby on-Rails-3Simple Form

Ruby on-Rails Problem Overview


I am trying to define the action "savenew" in admin/photographers controller.

I have tried this:

<%= simple_form_for(:photographer_savenew, :action => 'savenew', :id  => params[:id],  :multipart => true ) do |f| %>

But the action in the form is still: /admin/photographers

When it should be: /admin/photographers/savenew

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

Is there a reason you're not using REST for this? It would make your life a lot easier and requires much less code. If you're set on using this custom action, you will need to specify the url and probably the method:

<%= simple_form_for @photographer, :url => savenew_photographers_path, :method => :post ... # etc

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRails beginnerView Question on Stackoverflow
Solution 1 - Ruby on-RailsPeter BrownView Answer on Stackoverflow