Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails http://localhost:3000/users/new 路由错误_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails http://localhost:3000/users/new 路由错误

Ruby on rails http://localhost:3000/users/new 路由错误,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我正在学习这个教程。我只是在标题为的部分中向用户模型添加了一些验证 当我转到时,我得到一个路由错误。但据我所知,溃败看起来不错。怎么了 用户_controller.rb class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(params[:user]) if @user.save flash

我正在学习这个教程。我只是在标题为的部分中向用户模型添加了一些验证

当我转到时,我得到一个路由错误。但据我所知,溃败看起来不错。怎么了

用户_controller.rb

class UsersController < ApplicationController
  def new
    @user = User.new
  end
  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "You signed up successfully"
      flash[:color]= "valid"
    else
      flash[:notice] = "Form is invalid"
      flash[:color]= "invalid"
    end
    render "new"
  end
end
Model user.rb

class User < ActiveRecord::Base
  attr_accessor :password
  EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  validates :username, :presence => true, :uniqueness => true, :length => { :in => 3..20 }
  validates :email, :presence => true, :uniqueness => true, :format => EMAIL_REGEX
  validates :password, :confirmation => true #password_confirmation attr
  validates_length_of :password, :in => 6..20, :on => :create
end
class用户true,:university=>true,:length=>{:in=>3..20}
验证:email,:presence=>true,:university=>true,:format=>email\u REGEX
验证:password,:confirmation=>true#password_confirmation attr
验证以下内容的长度:password,:in=>6..20,:on=>:create
结束

将您的文件重命名为
userscoontroller
users\u controller.rb

另外,您在
User
类中的regexp
EMAIL\u REGEX
也会导致错误。您应该修改它,因为错误显示:

EMAIL_REGEX = /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i

将文件重命名为
userscoontroller
users\u controller.rb

另外,您在
User
类中的regexp
EMAIL\u REGEX
也会导致错误。您应该修改它,因为错误显示:

EMAIL_REGEX = /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i

将文件重命名为
userscoontroller
users\u controller.rb

另外,您在
User
类中的regexp
EMAIL\u REGEX
也会导致错误。您应该修改它,因为错误显示:

EMAIL_REGEX = /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i

将文件重命名为
userscoontroller
users\u controller.rb

另外,您在
User
类中的regexp
EMAIL\u REGEX
也会导致错误。您应该修改它,因为错误显示:

EMAIL_REGEX = /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i



你能提供错误信息吗?它应该可以工作;你能粘贴rake routes的输出吗??很抱歉,我刚才添加了一个错误。将user_controller.rb重命名为users_controller.rb。$rake routes DL不推荐使用,请使用Fiddle Prefix动词URI模式控制器#Action users_new GET/users/new(:format)users#new你能提供错误消息吗?应该可以;你能粘贴rake routes的输出吗??很抱歉,我刚才添加了一个错误。将user_controller.rb重命名为users_controller.rb。$rake routes DL不推荐使用,请使用Fiddle Prefix动词URI模式控制器#Action users_new GET/users/new(:format)users#new你能提供错误消息吗?应该可以;你能粘贴rake routes的输出吗??很抱歉,我刚才添加了一个错误。将user_controller.rb重命名为users_controller.rb。$rake routes DL不推荐使用,请使用Fiddle Prefix动词URI模式控制器#Action users_new GET/users/new(:format)users#new你能提供错误消息吗?应该可以;你能粘贴rake routes的输出吗??很抱歉,我刚才添加了错误。将user_controller.rb重命名为users_controller.rb。$rake routes DL不推荐使用,请使用Fiddle前缀动词URI模式controller#Action users_new GET/users/new(:format)users#newI刚刚这么做了。Error is ArgumentError in UsersController#new提供的正则表达式正在使用多行定位(^或$),这可能会带来安全风险。您是想使用\A和\z,还是忘记添加:multiline=>true选项?听起来您的模型中有不可靠的regexen,@joeyk16I刚刚将user.rb模型添加到我的问题中,修复了它,但现在有更多错误。现在很确定教程是错的。更多的错误。没有路由匹配{:action=>“create”,:controller=>“users”}它工作了。在路线中使用此选项。get'users/new'get':controller(/:action(/:id))(:format)'我刚做了。Error is ArgumentError in UsersController#new提供的正则表达式正在使用多行定位(^或$),这可能会带来安全风险。您是想使用\A和\z,还是忘记添加:multiline=>true选项?听起来您的模型中有不可靠的regexen,@joeyk16I刚刚将user.rb模型添加到我的问题中,修复了它,但现在有更多错误。现在很确定教程是错的。更多的错误。没有路由匹配{:action=>“create”,:controller=>“users”}它工作了。在路线中使用此选项。get'users/new'get':controller(/:action(/:id))(:format)'我刚做了。Error is ArgumentError in UsersController#new提供的正则表达式正在使用多行定位(^或$),这可能会带来安全风险。您是想使用\A和\z,还是忘记添加:multiline=>true选项?听起来您的模型中有不可靠的regexen,@joeyk16I刚刚将user.rb模型添加到我的问题中,修复了它,但现在有更多错误。现在很确定教程是错的。更多的错误。没有路由匹配{:action=>“create”,:controller=>“users”}它工作了。在路线中使用此选项。get'users/new'get':controller(/:action(/:id))(:format)'我刚做了。Error is ArgumentError in UsersController#new提供的正则表达式正在使用多行定位(^或$),这可能会带来安全风险。您是想使用\A和\z,还是忘记添加:multiline=>true选项?听起来您的模型中有不可靠的regexen,@joeyk16I刚刚将user.rb模型添加到我的问题中,修复了它,但现在有更多错误。现在很确定教程是错的。更多的错误。没有路由匹配{:action=>“create”,:controller=>“users”}它工作了。在路线中使用此选项。获取“用户/新的”获取:“控制器(/:操作(/:id))(:格式)”