Rails 3 route problem -


after solving other problem routes , have one.

i have route in routes.rb:

  match "user/create_new_password/:reset_password_key" =>"users#create_new_password", :via=>[:post, :get], :as=>:create_new_password  

i can test in functional tests this:

  test "should create new password "     post :create_new_password, {:user=>{:password=>"123456", :password_confirmation=>"123456"}, :reset_password_key=>user.reset_password_key} end  

in view, have following form:

  =simple_form_for @user, :url=>create_new_password_path |f|     =f.input :password, :label=>i18n.t("activerecord.attributes.user.email")     =f.input :password_confirmation, :label=>i18n.t("activerecord.attributes.user.password_confirmation")     =f.submit i18n.t "activerecord.actions.user.create_new_password"   

when submit form, get:

  no route matches "/user/create_new_password/oqqxytgjykxxgvbastswtmnipmopsjcrzlgzmjzlsbytjvcvdpo"  

the big string, reset_password_key.

i have tested in functional tests same value reset_password_key.

the relevant output rake routes is:

  create_new_password post|get /user/create_new_password/:reset_password_key(.:format) {:controller=>"users", :action=>"create_new_password"}  

i'm missing something...

as answered binarymuse's comment, i've found went wrong... checked request in firebug , found _method=put being sent post. rails cleverness detected i'm editing , existing instance of user (@user), defaults pots put, using param _method.

the problem in routes haven't method put in :via array. changed to:

   match "user/create_new_password/:reset_password_key" =>"users#create_new_password",:via=>[:get, :put], :as=>:create_new_password  

and in controller:

  def create_new_password    if request.put?       #change password    else      #render template    end  end  

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -