similar to: Consequences of overriding update_attribute to force validation?

Displaying 20 results from an estimated 7000 matches similar to: "Consequences of overriding update_attribute to force validation?"

2006 Feb 27
4
update_attribute with Validation?
Does anyone know of a way to update individual attributes with validation? update_attribute disables the validation checks in the record model, so I''m wondering if there''s a workaround for this. In my application, I want to allow the user to update some or all the attributes without having to enter :password and :password_confirmation, both of which are subject to
2006 Jan 17
2
update_attribute and validations
Just in case it saves someone else the several hours of insanity I just went through, update_attributes will not save unless the model validations are satisfied, but update_attribute (the singular form) will save the attribute to the database even if the model validations would fail! This appears to be a feature, not a bug (http://api.rubyonrails.com/classes/ActiveRecord/Base.html) although
2008 Aug 25
2
to catch exception from update_attribute
Hi begin ActiveRecord::Base.transaction do pb_status_history = ProblemStatusHistory.new pb_status_history.problem_id = @problem.id pb_status_history.problem_status_id = @problem.problem_status_id pb_status_history.save! ret_val=@problem.update_attribute("problem_status_id",''ab'') if ret_val==false
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two password-attributes in my User model: attr_accessor :password, :password_confirmation I have validations on these attributes, and I need them to work both on create and update, since I have pages for changing and resetting the password. Now when I want to update just the user''s login name, I guess I have the next
2007 Nov 21
3
update_attribute weirdness in edge
If I am changing a boolean value, no matter what approach I take, I get the same results: lets say table "users" has an "enabled" field that is boolean: user = User.find(1) user.enabled.toggle NoMethodError: undefined method `toggle'' for false:FalseClass user = User.find(1) toggle(user.enabled) NoMethodError: undefined method `toggle'' for
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is something borked? >> c=Contact.last => #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone: 2147483647, account_id: 8, created_at: "2009-11-27 18:16:25", updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone: false,
2008 Apr 28
1
update_attribute overwrites existing attributes with NULL.
Hmm. When using update_attribute from within a worker method, it seems that Backgroundrb inserts null values into all attributes that are not explicitly set. Is this possible/true?
2006 Apr 21
2
update_attribute... only ONE
Hi, I was reading the messages at <http://wrath.rubyonrails.org/pipermail/rails/2005-December/006969.html> http://wrath.rubyonrails.org/pipermail/rails/2005-December/006969.html, Subject: [Rails] update_attribute send updates every field, why? Well, I am having the same problem, and I do have a binary column where I am storing files. Also, I am calling a web service so I can send the
2006 Dec 08
9
How to update partial attributes of a object from a form?
I have a user table, and it has forty columns, including name, gender, address, email, phone... So my @user object will have forty attributes. I divide these attributes into 4 groups... namely ''general info'', ''personal info'', ''contact info''... and I make separate forms to edit these 4 different group attributes. The problem is when I update
2009 Jun 22
4
modal validation not works
Hi everyone, i have 20 fields in users table. in my admin profile module the admin can modify his infomation. but only 12 fields he can able to modify. so in my controller if params[ :profileinfo ][:first_name] @profileinfo.update_attribute(:first_name,params[ :profileinfo ][:first_name]) end the above simply saves what i enter into the field.why it doesnot consider the modelvalidation.
2008 Apr 19
1
update and update_attribute woes
i can not get update to work via controller/server. it works via console ??? this is what i get when i run it Club Load (0.005893) SELECT * FROM clubs WHERE (clubs."id" = 3) SQL (0.000570) BEGIN SQL (0.000454) COMMIT club.update_attributes(:state => "CA") or Club.update(3, :state => "CA") what am i overlooking?
2006 Jan 04
0
update_attribute works, update_attributes doesn''t, why?
Hello again... so I narrowed my problem down. For some reason, while using login_generator, any User object I pull from the DB can be updated one attribute at a time using update_attribute, but when I try and do update_attributes it fails every time. Is this a limitation with login_generator that I don''t know about, or is there a way around this? I also tried the .update method and
2006 Jun 21
5
model with not te be updated attributes ?
Hi List, I have a table that contains several fields that must be initialized when first created, but may not be altered afterwards (when updating the other fields) because they can be changed by external processes. I noticed that the ActiveRecord update commands (even update_attribute) only seem to work by loading the complete record, changing fields that need to be changed and doing a full
2011 Oct 12
2
update_attribute - effecting multiple attributes
Anybody know why this: User.find(current_user).update_attribute(:last_subject, params[:subject_id]) results in this: AREL (0.6ms) UPDATE "users" SET "last_subject" = 4, "encrypted_password" = ''f470e6e76203973146c3b07e8b31c976b19cb23a9bf37485ad1911687cdc7a29'', "updated_at" = ''2011-10-12 13:43:21.727558'' WHERE
2006 Jun 27
1
user.save now workie, but user.update_attributes does
In my User model, I had this: def update_last_login_time self.last_login = Time.now self.save end But last_login was not being set. When I changed it to this it worked: self.update_attribute( :last_login, Time.now ) Any ideas why? ~S
2007 Jan 10
6
Updating an attribute in db
Hello I am a Ruby newbie, thus a rather simple question. My list view shows table records and enables user to click a button in order to change value of one attribute in given record. I use this code to invoke a method from controller: <%= button_to "Change", { :action => "edit", :id => prog.id_prog } %> My method looks like this (just a simple one - to set the
2006 Jan 23
3
Clearing a file_column-type field
So I am now able to set/upload an image to my app using file_column, with a little bit of a change to the code. I can change the image using an Edit page, but I''m trying to figure out what to do if the user wants to remove the image. I tried adding a Remove Image link in my list, but I''m not sure what to do in the remove_image method in my controller. I tried setting the
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture- driven way of spec-ing or mocking. How the heck to you mock this so the code at line (2) and (4) work right? I''m still struggling with mocks but it seems like this can be done. Forgive the naivety of this question. 1. def change_quantity 2. @line_item = LineItem.find_by_id(params[:id]) 3. unless
2009 Jan 18
2
after_save -- stack level too deep
Hi all, I''m running into a brick wall trying to figure out my problem here. I have a model that has a boolean property called "paid". I''d like to add the following to my model: def after_save self.amount == self.splits.sum(:amount) ? self.update_attribute (:paid, true) : self.update_attribute(:paid, false) end The problem is, when I do this I get an error that
2005 Apr 23
7
Validation question
Hi all, Is there a way to invoke validations at times other than save, create and update? I know that I can do this by writing my own validation checks using errors.add_[blah], but I''d like to leverage the existing validation code. What I have is two sets of fields in a record, set A and set B. Both sets must be validated on record create. However, the trouble is that after