similar to: update_without_callbacks?

Displaying 20 results from an estimated 6000 matches similar to: "update_without_callbacks?"

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
2008 Mar 11
6
saving an ActiveRecord without trigging the callbacks
Hello, How can I save an ActiveRecord without trigger before_save, after_save, etc? Thanks for the help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group,
2008 Jul 28
1
callback executed like after_save but after transaction
I''m trying to add some code for my ActiveRecord class so that it is executed whenever an object is updated, this code is a seperate process that reads from the same table represented by my model class so when it runs it needs the database to be up to date. In the following situation this is fine: # MyModel def after_save `/usr/local/bin/update_models -i #{self.id}` end # controller
2006 Aug 15
1
Update attribute without validations or any save hooks?
If I wanted to update an attribute with calling any validation or any of the before_save and after_save hooks, how would I go about doing this? Supposed the update_attribute method calls the before and after save methods. Thanks for your help. -- Posted via http://www.ruby-forum.com/.
2006 Jul 17
5
Keeping attributes of two models in sync
Hi, I have a Product and a corresponding Keyword (1:1 via belongs_to and has_one). I want to ensure, that two attributes (:name) of the two models alway stay in sync. What''s the easiest way to accomplish that? I did play around with before_/after_save hooks and with AR::Observers but in the end I''d always get infinite recursion... Thanks, Timo
2008 Feb 08
2
update_Attributes stale Object error
Hi, IN one of my unit tests I get an ActiveRecord::StaleObjectError: Attempted to update a stale object object.save! in object I have apart from other stuff an after_save method, which calls object.assosication.update_attributes(...) If I remove that line from my code my tests succeeds. Unfortunetly, I do not understand why an update_attributes call can generate an StaleObjectError. Maybe
2009 Mar 29
2
after_create and after_save
Hi, AFAIK after_create is called after_save if the entry does not exist in the DB. Is there a way to tell if a specific model is new or not in after_save? I have to do something like: def after_save add_to_history ''save'' end def after_create add_to_history ''create'' end However after_save is called when creating too. -- cheers, M.
2006 Jul 17
2
Very strange after_save problem. Please help.
I have a very strange problem here. I do not get this. So any help is greatly appreciated. Basically I have a model that calls a method in the background process in the "after_save" method. Let''s call the model products. So what happens is this: 1. I create a new product. 2. Everything works and the product is saved with id 13. 3. A method is called in my background
2006 Jul 17
2
after_save deletes is an exception is raised?
Does after_save in a model delete if an exception is raised in there? I simply did def after_save raise ''hmmm'' end and it raised the exception but there was nothing in the database. I removed that entire method and its in the database. Is this correct? Thank You, Ben Johnson E: bjohnson@contuitive.com -------------- next part -------------- An HTML attachment was
2010 Oct 01
20
Paperclip not executing FFMPEG properly
Im using a customs processor to run ffmpeg on a video to create a thumbnail. So far so good. Except when I do: cmd = "-i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/q.flv" success = Paperclip.run(''ffmpeg'', cmd) Console is reporting: ffmpeg ''-i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/stream, 16824,1.mpeg -f flv -s 320x240
2006 May 09
2
handling file upload onto local filesystem.
Hi, I have a multipart form upload field uploaded through <%= file_field("profile", "profile") %> Once a submit happens, the action basically does something like: profile = Profile.new(params["picture"]) This invokes the models = to method: def picture=(picture_field) ...do a bunch of assignments here end def validate ... do a bunch of validations
2010 Jul 28
1
paperclip, authlogic and callback issue
I use authlogic for authentication and paperclip for handling user''s profile picture attachments. I use the following method to get the current_user def current_user_session return @current_user_session if defined? (@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user)
2010 Aug 18
11
When after_save isn't after the save....
I have a Production model, which represents a farmer''s crop. After create (via after_save) I call a method that creates one or more Supply models, which represent a week of anticipated product harvest. After each of those are created, a class method gets called that tries to match each new Supply with outstanding orders for the same time period. If a match is made, a transaction (an
2010 May 12
2
How to add an after_save callback on runtime on a particular instance
class User < AR end user = User.new Let''s say that I have a user instance with me. After this record is saved I want an after_save callback which would print the id of the record. The only catch is that I am not allowed to change the User class. How can I accomplish my goal? Is that even possible to add an after_save callback on a particular instance object. Any metaprogramming
2006 Aug 23
5
validation, concurrency, and transactions
Hi, Something has been bothering me about model validation: how do I know that the database has not changed in between when I validate my model''s data, and when it actually gets saved to the database? As a simple example, say I have a User model like: class User validates_uniqueness_of :username end When this gets saved to the database, the validation code checks that there is
2008 Dec 13
3
session In the model
Hi i have the model SDTicket which has a field modified_by_id and it has to take data from session[:id] Now this SDTicket model has many associated models like Activity one of them So when ever an activity happens then also the value in session[:id] is to be go to modified_by_id field SDTicket has_many activities Activity belongs to SDTicket So for that what I am trying is in Activity
2009 Feb 24
2
Displaying line breaks & paragraphs using 'simple_format' ?
Hi there, I need to: 1. STORE a text of the below format in a (MySQL) database (using a ''textarea''), and then 2. RETRIEVE & DISPLAY it in exactly the same format (meaning: keeping all paragraphs/line breaks). The intended text format looks like this: *** Blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah, blah blahblah. <- NEW
2007 May 06
3
Using session-type data in an ActiveRecord callback...
Any suggestions on how best to gain access to session-type information while in an ActiveRecord callback, such as after_save? I am encrypting some information in the database, using the generalized encryption/decryption handler in "Agile Web Development With Rails" (p 375ff). I got it working, and now I want to reference a session field (a user PIN) which is NOT stored in the
2008 Apr 01
1
"Undefined method merge" when using sweeper
Hi, I''m trying to use sweepers for the first time and got a problem - I get "undefined method `merge'' for "/signature/ f2d7c7c66450b169.html":String". The "/signature/f2d7c7c66450b169.html" part of the error message is the cached page. Here''s my sweeper: class FooSweeper < ActionController::Caching::Sweeper observe Foo def
2006 Apr 04
6
Oracle Problem. Maybe driver
EVerything runs ok on my local machine but when i copy my app to our solaris server everything is fine until i try updating/inserting something into the DB. This is the error message : wrong number of arguments (1 for 0) RAILS_ROOT: config/.. Application Trace | Framework Trace | Full Trace