ruby on rails 3 - Updating a model from another controller -
i update "user" model has column named "verification_code_confirmation" "verifications" controller
i had tried writing code
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
and
index.html.erb verifications view.
<%= form_for(@user) |f| %> <div><%= f.label :verification_code_confirmation %><br /> <%= f.number_field :verification_code_confirmation %></div> <% end %>
user model
class user < activerecord::base # include default devise modules. others available are: # :confirmable, :lockable, :timeoutable , :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # setup accessible (or protected) attributes model attr_accessible :email, :password, :password_confirmation, :remember_me, :verification_code_confirmation, :phone end end
i have updated to
if @user.update_attributes(params[:user])
how do it? have looked around in net update column through verification controller couldn't.
ruby-on-rails-3 ruby-on-rails-3.2
No comments:
Post a Comment