在Rails中生成控制器

时间:2013-05-22 21:00:33

标签: ruby-on-rails controller terminal

当我尝试使用以下命令生成控制器时出现问题:

rails generate controller profiles show

我已经尝试过这个解决方案,但没有用:

script/rails generate controller profiles show
./script/rails generate controller profiles show

一些错误:

/Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/format.rb:17:in `check_validity!': Either :with or :without must be supplied (but not both) (ArgumentError)
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validator.rb:143:in `initialize'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/with.rb:82:in `new'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/with.rb:82:in `block in validates_with'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/with.rb:81:in `each'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/with.rb:81:in `validates_with'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/validates.rb:99:in `block in validates'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/validates.rb:90:in `each'
from /Users/italoborges/.rvm/gems/ruby-1.9.3-p392/gems/activemodel-3.2.12/lib/active_model/validations/validates.rb:90:in `validates'
from /Volumes/Development/development/ruby/Tasker/0001_Hello/04_Desenvolvimento/Ruby/app/models/user.rb:14:in `<class:User>'

我正在使用Rails 3.2和Ruby 1.9.3。

1 个答案:

答案 0 :(得分:1)

解决

错误发生在文件user.rb中。不完整的一行。