爲什麼他使用:put
,我應該如何路由它?有什麼不同之處:方法=>:put和=>:後+路由
形式:
<p>Sign Up</p>
<%= form_for @user, :as => :user, :url => new_user_path, :method => :put do |f| %>
...
<% end %>
有在最後一個:put
,正如你所see他沒有表現如何路由:put
- 方法。
我route.rb看起來是這樣的:
Calendar::Application.routes.draw do
root "welcome#index"
get "user/change_pw"
get "user/forgot_pw"
get "user/new" => "user#new"
get "user/sent_pw"
get "user/sign_in" => "user#sign_in"
get "user/signed_out" => "user#signed_out"
get "welcome/index"
post "user/sign_in" => "user#login"
post "user/new" => "user#register"
end
如果我點擊 「註冊」 出現以下錯誤:
沒有路由匹配[PUT]「/用戶/新「
任何想法?
我改變了它,但它仍然沒有工作:'丟失模板user/user_new,application/user_new {:locale => [:en],:formats => [:html],:handlers => [:erb,: builder,:raw,:ruby,:jbuilder,:coffee]}。搜索:*「../ Calendar/app/views」# – Ismoh
控制檯顯示錯誤在第29行,這是這樣的:'render:action =>「user_new」'這是方法:'def register @user = User.new(params [:user]) if @ user.valid? @ user.save session [:user_id] = @ user.id flash [:notice] ='Die Anmeldung war erfolgreich。' redirect_to:root else render:action =>「user_new」 end end' – Ismoh
解決方案是:'render:action =>「new」'。不管怎麼說,多謝拉 :) – Ismoh