Ruby on rails Rails 4.0-缺少方法:模型存在选项问题

Ruby on rails Rails 4.0-缺少方法:模型存在选项问题,ruby-on-rails,ruby,ruby-on-rails-4,activeadmin,Ruby On Rails,Ruby,Ruby On Rails 4,Activeadmin,我对rails 4应用程序有一个问题。在我的用户模型中(实际上,它与任何其他模型相同),我不能将与_options方法一起使用。如果我有这样的代码: class User < ActiveRecord::Base # ... with_options :unless => :is_person do |u| u.validates :company_name, presence: true u.validates :company_address, pre

我对rails 4应用程序有一个问题。在我的用户模型中(实际上,它与任何其他模型相同),我不能将
与_options
方法一起使用。如果我有这样的代码:

class User < ActiveRecord::Base

  # ...

  with_options :unless => :is_person do |u|
    u.validates :company_name, presence: true
    u.validates :company_address, presence: true
  end

  # ...
end
class用户:是|人做| u|
u、 验证:公司名称,状态:true
u、 验证:公司地址,状态:true
结束
# ...
结束
在我的应用程序启动时,我会收到这样一条消息:

> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/mike/.rvm/gems/ruby-2.0.0-p0@leo4/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `  with_options' for #<Class:0x007fed97c0a6e8> (NoMethodError)
    from /Users/mike/dev/leo4/app/models/user.rb:57:in `<class:User>'
...
>启动WEBrick
=>Rails 4.0.0应用程序在上开始开发http://0.0.0.0:3000
=>运行“rails服务器-h”以获得更多启动选项
=>Ctrl-C关闭服务器
退出
/Users/mike/.rvm/gems/ruby-2.0.0-p0@leo4/gems/activerecord-4.0.0/lib/active_-record/dynamic_-matchers.rb:22:in'method_-missing':未定义的方法'with#options'(命名方法错误)
from/Users/mike/dev/leo4/app/models/user.rb:57:in`'
...
如果此块为空且没有任何验证,则图片是相同的。 一些非常奇怪的事情正在发生,因为如果我删除这些行,启动一个控制台并检查它,这个方法就存在了。看起来这只是一个启动时间问题(?)

有什么想法吗?谢谢

另外,My Gemfile.lock:

GIT
  remote: git://github.com/gregbell/active_admin.git
  revision: 72a9c30cef47b3f38c38039de021aaa3194c188b
  branch: rails4
  specs:
    activeadmin (0.6.0)
      arbre (>= 1.0.1)
      bourbon (>= 1.0.0)
      coffee-rails (>= 3.2.0)
      devise (>= 3.0.2)
      formtastic (>= 2.3.0.rc2)
      inherited_resources (>= 1.4.1)
      jquery-rails (>= 3.0.0)
      jquery-ui-rails (>= 4.0.0)
      kaminari (>= 0.13.0)
      rails (>= 3.2.0)
      ransack (>= 1.0.0)
      sass-rails (>= 3.2.0)

GIT
  remote: git://github.com/justinfrench/formtastic.git
  revision: cd6cb88f28ea7444267802ced8e5ec0f5cfd0f90
  branch: master
  specs:
    formtastic (2.3.0.rc2)
      actionpack (>= 3.0)

GIT
  remote: git://github.com/sporkrb/spork-rails.git
  revision: 3224f84d8c31fcb0894e9a43f6c3ac67e3aa0d71
  specs:
    spork-rails (3.2.1)
      rails (>= 3.0.0, < 5)
      spork (>= 1.0rc0)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.0)
      actionpack (= 4.0.0)
      mail (~> 2.5.3)
    actionpack (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
    activerecord (4.0.0)
      activemodel (= 4.0.0)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.0)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    annotate (2.5.0)
      rake
    arbre (1.0.1)
      activesupport (>= 3.0.0)
    arel (4.0.0)
    atomic (1.1.13)
    bcrypt-ruby (3.1.1)
    bourbon (3.1.8)
      sass (>= 3.2.0)
      thor
    builder (3.1.4)
    cancan (1.6.10)
    capybara (2.1.0)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    capybara-webkit (1.0.0)
      capybara (~> 2.0, >= 2.0.2)
      json
    coffee-rails (4.0.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0.beta, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    cucumber (1.3.7)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.1)
      multi_json (~> 1.7.5)
      multi_test (>= 0.0.2)
    database_cleaner (1.0.1)
    devise (3.0.2)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      warden (~> 1.2.3)
    diff-lcs (1.2.4)
    draper (1.2.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      request_store (~> 1.0.3)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.2.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.2.1)
      factory_girl (~> 4.2.0)
      railties (>= 3.0.0)
    faraday (0.8.8)
      multipart-post (~> 1.2.0)
    ffaker (1.18.0)
    gherkin (2.12.1)
      multi_json (~> 1.3)
    has_scope (0.6.0.rc)
      actionpack (>= 3.2, < 5)
      activesupport (>= 3.2, < 5)
    hashie (2.0.5)
    hike (1.2.3)
    httpauth (0.2.0)
    i18n (0.6.5)
    inherited_resources (1.4.1)
      has_scope (~> 0.6.0.rc)
      responders (~> 1.0.0.rc)
    jbuilder (1.4.2)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.0.4)
      jquery-rails
      railties (>= 3.1.0)
    json (1.8.0)
    jwt (0.1.8)
      multi_json (>= 1.5)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    libv8 (3.11.8.17)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.23)
    mini_portile (0.5.1)
    minitest (4.7.5)
    multi_json (1.7.9)
    multi_test (0.0.2)
    multipart-post (1.2.0)
    nokogiri (1.6.0)
      mini_portile (~> 0.5.0)
    oauth2 (0.8.1)
      faraday (~> 0.8)
      httpauth (~> 0.1)
      jwt (~> 0.1.4)
      multi_json (~> 1.0)
      rack (~> 1.2)
    omniauth (1.1.4)
      hashie (>= 1.2, < 3)
      rack
    omniauth-facebook (1.4.1)
      omniauth-oauth2 (~> 1.1.0)
    omniauth-mailru (1.0.0)
      omniauth (~> 1.0)
      omniauth-oauth2 (~> 1.0)
    omniauth-oauth2 (1.1.1)
      oauth2 (~> 0.8.0)
      omniauth (~> 1.0)
    omniauth-odnoklassniki (0.0.4)
      omniauth (~> 1.0)
      omniauth-oauth2 (~> 1.0)
    omniauth-vkontakte (1.2.0)
      multi_json
      omniauth (~> 1.1.0)
      omniauth-oauth2 (~> 1.0)
    orm_adapter (0.4.0)
    polyamorous (0.6.3)
      activerecord (>= 3.0)
    polyglot (0.3.3)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.0)
      actionmailer (= 4.0.0)
      actionpack (= 4.0.0)
      activerecord (= 4.0.0)
      activesupport (= 4.0.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.0)
      sprockets-rails (~> 2.0.0)
    railties (4.0.0)
      actionpack (= 4.0.0)
      activesupport (= 4.0.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.0)
    ransack (1.0.0)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      polyamorous (~> 0.6.0)
    rdiscount (2.1.6)
    rdoc (3.12.2)
      json (~> 1.4)
    redis (3.0.4)
    redis-actionpack (4.0.0)
      actionpack (~> 4)
      redis-rack (~> 1.5.0)
      redis-store (~> 1.1.0)
    redis-activesupport (4.0.0)
      activesupport (~> 4)
      redis-store (~> 1.1.0)
    redis-rack (1.5.0)
      rack (~> 1.5)
      redis-store (~> 1.1.0)
    redis-rails (4.0.0)
      redis-actionpack (~> 4)
      redis-activesupport (~> 4)
      redis-store (~> 1.1.0)
    redis-store (1.1.4)
      redis (>= 2.2)
    ref (1.0.5)
    request_store (1.0.5)
    responders (1.0.0.rc)
      railties (>= 3.2, < 5)
    rspec-core (2.14.5)
    rspec-expectations (2.14.2)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.3)
    rspec-rails (2.14.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    sass (3.2.10)
    sass-rails (4.0.0)
      railties (>= 4.0.0.beta, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    sdoc (0.3.20)
      json (>= 1.1.3)
      rdoc (~> 3.10)
    simple_form (1.4.1)
    simplecov (0.7.1)
      multi_json (~> 1.0)
      simplecov-html (~> 0.7.1)
    simplecov-html (0.7.1)
    slim (2.0.1)
      temple (~> 0.6.6)
      tilt (>= 1.3.3, < 2.1)
    slim-rails (2.0.1)
      actionpack (>= 3.0, < 4.1)
      activesupport (>= 3.0, < 4.1)
      railties (>= 3.0, < 4.1)
      slim (~> 2.0)
    spork (1.0.0rc3)
    sprockets (2.10.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    sqlite3 (1.3.7)
    temple (0.6.6)
    therubyracer (0.11.4)
      libv8 (~> 3.11.8.12)
      ref
    thor (0.18.1)
    thread_safe (0.1.2)
      atomic
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (1.3.0)
      coffee-rails
    tzinfo (0.3.37)
    uglifier (2.1.2)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    warden (1.2.3)
      rack (>= 1.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  activeadmin!
  annotate (>= 2.5.0)
  cancan (= 1.6.10)
  capybara
  capybara-webkit
  coffee-rails (~> 4.0.0)
  cucumber
  database_cleaner (< 1.1.0)
  devise (= 3.0.2)
  draper (~> 1.0)
  factory_girl_rails
  ffaker
  formtastic!
  jbuilder (~> 1.2)
  jquery-rails (= 3.0.4)
  kaminari (= 0.14.1)
  omniauth (= 1.1.4)
  omniauth-facebook
  omniauth-mailru
  omniauth-odnoklassniki
  omniauth-vkontakte
  rails (= 4.0.0)
  rdiscount
  redis-rails (~> 4.0.0)
  rspec-rails (~> 2.0)
  sass-rails (~> 4.0.0)
  sdoc
  simple_form (= 1.4.1)
  simplecov
  slim-rails (= 2.0.1)
  spork-rails!
  sqlite3
  therubyracer
  turbolinks (= 1.3.0)
  uglifier (>= 1.3.0)
GIT
远程:git://github.com/gregbell/active_admin.git
修订:72A9C30CEF47B3F38C38039DE021A3194C188B
分行:铁路4
规格:
activeadmin(0.6.0)
arbre(>=1.0.1)
波旁威士忌(>=1.0.0)
咖啡轨(>=3.2.0)
设计(>=3.0.2)
formtastic(>=2.3.0.rc2)
继承的_资源(>=1.4.1)
jquery rails(>=3.0.0)
jquery ui rails(>=4.0.0)
卡米纳里(>=0.13.0)
轨道(>=3.2.0)
搜查(>=1.0.0)
sass轨道(>=3.2.0)
吉特
远程:git://github.com/justinfrench/formtastic.git
修订:cd6cb88f28ea7444267802ced8e5ec0f5cfd0f90
分支机构:硕士
规格:
formtastic(2.3.0.rc2)
actionpack(>=3.0)
吉特
远程:git://github.com/sporkrb/spork-rails.git
修订:3224f84d8c31fcb0894e9a43f6c3ac67e3aa0d71
规格:
spork导轨(3.2.1)
轨道(>=3.0.0,<5)
spork(>=1.0rc0)
宝石
远程:https://rubygems.org/
规格:
actionmailer(4.0.0)
actionpack(=4.0.0)
邮件(~>2.5.3)
actionpack(4.0.0)
动态支持(=4.0.0)
生成器(~>3.1.0)
erubis(~>2.7.0)
机架(~>1.5.2)
机架测试(~>0.6.2)
activemodel(4.0.0)
动态支持(=4.0.0)
生成器(~>3.1.0)
activerecord(4.0.0)
activemodel(=4.0.0)
activerecord-已弃用的查找程序(~>1.0.2)
动态支持(=4.0.0)
arel(~>4.0.0)
activerecord-Disprecated_查找程序(1.0.3)
activesupport(4.0.0)
i18n(~>0.6,>=0.6.4)
小型测试(~>4.2)
多重json(~>1.3)
线程安全(~>0.1)
tzinfo(~>0.3.37)
注释(2.5.0)
耙
arbre(1.0.1)
activesupport(>=3.0.0)
阿雷尔(4.0.0)
原子(1.1.13)
bcrypt红宝石(3.1.1)
波旁威士忌(3.1.8)
sass(>=3.2.0)
雷神
建造商(3.1.4)
坎坎(1.6.10)
水豚(2.1.0)
mime类型(>=1.16)
nokogiri(>=1.3.3)
机架(>=1.0.0)
机架测试(>=0.5.4)
xpath(~>2.0)
水豚网络工具包(1.0.0)
水豚(~>2.0,>=2.0.2)
json
咖啡架(4.0.0)
咖啡脚本(>=2.2.0)
钢轨(>=4.0.0.beta,<5.0)
咖啡脚本(2.2.0)
咖啡脚本源
execjs
coffee脚本源(1.6.3)
黄瓜(1.3.7)
建造商(>=2.1.2)
差异lcs(>=1.1.3)
小黄瓜(~>2.12.1)
多重json(~>1.7.5)
多重检验(>=0.0.2)
数据库清理器(1.0.1)
设计(3.0.2)
bcrypt红宝石(~>3.0)
orm_适配器(~>0.1)
钢轨(>=3.2.6,<5)
典狱长(~>1.2.3)
差异lcs(1.2.4)
带式输送器(1.2.1)
actionpack(>=3.0)
activesupport(>=3.0)
请求存储(~>1.0.3)
erubis(2.7.0)
execjs(1.4.0)
多重json(~>1.0)
工厂女孩(4.2.0)
activesupport(>=3.0.0)
工厂导轨(4.2.1)
工厂女孩(~>4.2.0)
钢轨(>=3.0.0)
法拉第(0.8.8)
多部分post(~>1.2.0)
法克尔(1.18.0)
小黄瓜(2.12.1)
多重json(~>1.3)
具有_范围(0.6.0.rc)
actionpack(>=3.2,<5)
activesupport(>=3.2,<5)
哈西(2.0.5)
徒步旅行(1.2.3)
httpauth(0.2.0)
i18n(0.6.5)
继承的资源(1.4.1)
具有_范围(~>0.6.0.rc)
响应者(~>1.0.0.rc)
jbuilder(1.4.2)
activesupport(>=3.0.0)
multi_json(>=1.2.0)
jquery rails(3.0.4)
钢轨(>=3.0,<5.0)
雷神(>=0.14,<2.0)
jQueryUIRails(4.0.4)
jquery rails
钢轨(>=3.1.0)
json(1.8.0)
jwt(0.1.8)
multi_json(>=1.5)
卡米纳里(0.14.1)
actionpack(>=3.0.0)
activesupport(>=3.0.0)
libv8(3.11.8.17)
邮件(2.5.4)
mime类型(~>1.16)
树梢(~>1.4.8)
mime类型(1.23)
迷你端口(0.5.1)
小型试验(4.7.5)
多线程json(1.7.9)
多重检验(0.0.2)
多部分post(1.2.0)
nokogiri(1.6.0)
迷你端口(~>0.5.0)
oauth2(0.8.1)
法拉第(~>0.8)
httpauth(~>0.1)
jwt(~>0.1.4)
多重json(~>1.0)
机架(~>1.2)
omniauth(1.1.4)
hashie(>=1.2,<3)
支架
omniauth facebook(1.4.1)
omniauth-oauth2(~>1.1.0)
omniauth mailru(1.0.0)
omniauth(~>1.0)
omniauth-oauth2(~>1.0)
omniauth-oauth2(1.1.1)
oauth2(~>0.8.0)
omniauth(~>1.0)
omniauth odnoklassniki(0.0.4)
omniauth(~>1.0)
omniauth-oauth2(~>1.0)
omniauth vkontakte(1.2.0)
多线程json
omniauth(~>1.1.0)
omniauth-oauth2(~>1.0)
orm_适配器(0.4.0)
多元性(0.6.3)
activerecord(>=3.0)
polyglot(0.3.3)
机架(1.5.2)
机架测试(0.6.2)
机架(>=1.0)
轨道(4.0.0)
行为