I don't understand what's happening here. I want to put a button_to
in my (haml) view. If I do this:
=button_to( "New", {:action => "new"}, {} )
the page generated has:
<form action="/cached_input_files/new" class="button_to" method="post">
<div>
<input type="submit" value="New" />
<input name="authenticity_token" type="hidden" value="..blah.." />
</div>
</form>
which is OK, but I need to address a different controller. But if I try to specify the controller:
=button_to( "New", {:action => "new", :controller => "editor"}, {} )
I get:
<form action="/assets?action=new&controller=editor" class="button_to" method="post">
<div>
<input type="submit" value="New" />
...
I expected the action
to be "/editor/new"
, and I have no idea why it isn't, nor how to correctly specify the controller I want to route to.
I'm using Rails 3.2.1.
You don't want to include the options in their own hash, I think this is confusing the interpreter.
=button_to( "New", :action => "new", :controller => "editor")
should do what you want.
Try
=button_to( "New", new_editor_path, :method => :get )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With