validation - Rails 3: how to update only 1 attribute? -


how can update 1 attribute in database without having insert validations?

e.g:

i have password presence = true. when want edit database, have pass password. want edit 1 field without passing password.

i've tried update_attribute, merge, none works.

thanks. donald

edit: validation, works on console, still puts password there.

here's validation:

 def password_validation_required?       encrypted_password.blank? || !@password.blank?     end 

and when submit form without password field, on console: (it puts blank on encrypted_password field)

 sql (0.3ms)  update "wsps" set "about" = 'gfg', "encrypted_password" = 'fcf538f9a588befec4ee2567754a42f05b3cd75f24919d49530426786491c3e1', "updated_at" = '2010-11-30 23:56:45.594168' ("wsps"."id" = 4) 

maybe controller isn't correct? have this:

if @wsp.update_attributes(params[:wsp]) 

my form:

<%= form_for(@wsp, :html => { :multipart => true } ) |f| %> 

thanks

validations , callbacks designed pretty hard ignore. like:

model.update_all({:my_attribute => 'x'}, {:id => id}) 

http://rubydoc.info/docs/rails/3.0.0/activerecord/relation:update_all


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -