我想更新"用户"具有名为" validation_code_confirmation"的列的模型来自" Verifications"控制器
我曾尝试编写此代码
class VerificationController < ApplicationController
def index
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to @user, :flash => { :success => "Successfully verified." }
else
render :action => 'edit'
end
end
和
index.html.erb用于验证视图。
<%= form_for(@user) do |f| %>
<div><%= f.label :verification_code_confirmation %><br />
<%= f.number_field :verification_code_confirmation %></div>
<% end %>
用户模型
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :verification_code_confirmation, :phone
end
end
我已更新到
if @user.update_attributes(params[:user])
我该怎么做?我在互联网上环顾四周,通过验证控制器更新了我的专栏,但我不能。