[英]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.