0
在我的路線,我有以下:完全改變URL行動
resource :login, only: [:new, :create, :destroy]
resources :users, only: [:new, :create] do
resources :notes
end
,但我想有網址「我的域/登錄」而不是「我的域名/登錄/新」和'我的域/註冊'而不是'我的域/用戶/新'。
我該怎麼辦?我曾嘗試以下,但它沒有工作:
match 'login' => 'login#new'
match 'register' => 'users#new'
resource :login, only: [:create, :destroy]
resources :users, only: [:create] do
resources :notes
end
這給了我錯誤
undefined local variable or method `logins_path' for #<#<Class:0x007fd99c40c608>:0x007fd99c87bdd8>
,而來訪的 '我的域名/登錄'
此解決方案並不能滿足我,因爲它仍然是更多鈔票的用戶訪問「/用戶/新」而不是「/註冊」 – guest
但正是因爲new_user_path更復雜仍然指向'/ users/new',但應該'/ register' – guest
你確定嗎?如果你有'資源:用戶,只有:[:create]'不應該有一個new_user_path。嘗試在你的控制檯中使用'rake routes'。 – Flauwekeul