Anuj
Anuj

Reputation: 35

Can't get Sinatra's PUT method to work with an ERB form

(I'm new to Sinatra)

I have, in my index.erb the following form:

<form method="post" action="play">
  <input type="hidden" name="_method" value="put" />
  <input type="button" value="Next" name="next" id="next" title="Next" />
      ...
</form>

and in my app's file (play.rb) I have the following:

put '/play' do
  ...
  ...
end

the .erb is under app\views\ and play.rb is under \app.

For the life of me, I can't get the play to be invoked. I've even tried using a post too with no luck. Based on another question asked here, I've included use Rack::MethodOverride for the _method hack. Any idea what I'm doing wrong?

Upvotes: 1

Views: 723

Answers (1)

three
three

Reputation: 8478

change the button to:

<input type="submit" value="Next" name="next" id="next" title="Next" />

unless you bind the button to some javascript action.

Upvotes: 3

Related Questions