Hi,
I'm trying to emulate a post from a HTML form. I've the following code in
erb:
<h1>Alterar Password</h1>
<% form_tag :action=>"reset_password", :method=>"put" do%>
<p>
<%=label_tag :password, "Nova password" %>
</p>
<p>
<%=password_field_tag :password, @password %>
</p>
<p>
<%=label_tag :password_confirmation, "Confirmação Password" %>
</p>
<p>
<%=password_field_tag :password_confirmation, @password_confirmation %>
</p>
<%=submit_tag "Alterar Password" %>
<%end %>
In my action I have something similar to this:
def reset_password
if request.get?
#do something for get
elsif request.put?
#do something for put
else
raise Webapp::BadRequestError
end
rescue Webapp::BadRequestError
logger.error("Invalid Request type. Client IP: "+request.remote_ip)
flash_error(:invalid_request)
redirect_to root_url
end
I've functional tests for put and get, and everything is fine. But when the
form is rendered and tested in a browser I can't get this working. In
Firefox, the output for the erb is something like:
<form
action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put"
method="post"><div style="margin:0;padding:0;display:inline"><input
name="authenticity_token" type="hidden"
value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div>
<p>
<label for="password">Nova password</label>
</p>
<p>
<input id="password" name="password" type="password" value="" />
</p>
<p>
<label for="password_confirmation">Confirmação Password</label>
</p>
<p>
<input id="password_confirmation" name="password_confirmation"
type="password" value="" />
</p>
<input name="commit" type="submit" value="Alterar Password" />
</form>
Everytime I submit the form I then hit in the Webapp::BadRequestError
Can someone help me get over this?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.