[英]Ruby on rails error with log in
我更改了文件中的一些內容,當創建用戶而不是轉到 user/1 時,它將轉到 user.1。 知道為什么會這樣嗎? 以下是日志摘錄的打印。 謝謝,
Started GET "/user.113" for 95.45.98.59 at 2016-04-18 23:39:53 +0000
ActionController::RoutingError (uninitialized constant UserController): activesupport (4.2.2) lib/active_support/inflector/methods.rb:261:in const_get'
activesupport (4.2.2) lib/active_support/inflector/methods.rb:261:inblock in constantize' activesupport (4.2.2) lib/active_support/inflector/methods.rb:259:in each'
activesupport (4.2.2) lib/active_support/inflector/methods.rb:259:ininject' activesupport (4.2.2)
如果您使用路由輔助方法,並且想要路由到特定資源的 url,請確保調用resource_path(resource)
而不是resources_path(resource)
。 請注意路線方法中的單數/復數區別。
如果我正確理解你的問題,你的控制器應該是這樣的;
class UsersController < ApplicationConroller
# ...
def create
# Create the user...
if @user.valid?
redirect_to user_path(@user) # redirects to `show` action
else
render :new # There are errors, so render the form with errors
end
end
# ...
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.