Web ショップで新しい顧客アカウントをアクティブ化するためのカスタム コントローラー アクションがあります。というモデルがありcustomer.rb
ます。モデルはキーを生成し、顧客にアクティベーション リンクを送信します。リンクはcustomers_controller.rb
および次のアクションにルーティングされます。
def activate_customer
@customer = Customer.find(params[:customer_id])
if @customer.present?
if @customer.activation_key == params[:activation_key]
@customer.activated = true
@customer.save
redirect_to :cart
else
redirect_to :root
end
else
redirect_to :root
end
end
最初はなしで試しました@customer.save
が、記録は更新されませんでした。前後にレイズしましたが@customer.activated = true
、すべて問題ないようです。唯一の問題は、レコードが更新されないことです。考えられる問題もチェックしましたが、そうではありません(チェックするために完全attar_accessible
に閉じました)。attr_accessible
何か案は?事前にサンクス!
*編集: のチェック値@customer.save
、戻り値false
...
*編集:
問題は Customer モデルでのパスワード検証にあるようです。検証は次のようになります。
# Validations
validates_presence_of :title, :country, :zipcode, :city, :street, :number, :first name, :lastname
validates :email, :presence => true, :uniqueness => true, :email => true
validates_confirmation_of :password, :unless => :validate?
validates_presence_of :password
この特定のコントローラー アクションの検証をスキップする方法はありますか? 一緒に考えてくれてありがとう!