1

我试图在多步向导上设置验证(使用 wicked gem 和这个GUIDE)。第一步我正在输入一些用户信息(使用设计 + 注册),但是当我提交时,我收到以下错误:

NoMethodError in RegistrationsController#create

undefined method `include?' for nil:NilClass
Rails.root: /Users/nelsonkeating/Desktop/remindeal1

Application Trace | Framework Trace | Full Trace
app/models/user.rb:54:in `active_or_address?'


Class User
  validates_presence_of :address, :presence => true, :if => :active_or_address?

  def active_or_address?
    status.include?('address') || active?
  end

 def active?
   status == 'active'
 end
4

1 回答 1

1

您需要将“状态”添加到用户模型,并从向导控制器将其设置为 step 的值。

该指南指导您在“解决方案”部分的开头执行迁移:

class ProductStatus < ActiveRecord::Migration

  def up
    add_column :products, :status, :string
  end

  def down
    remove_column :product, :status
  end

end
于 2013-03-07T19:22:34.293 回答