similar to: Catch 22 with after_save. Please help.

Displaying 20 results from an estimated 1000 matches similar to: "Catch 22 with after_save. Please help."

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 19
0
save without after_save, after_create, after_update?
How to update attribute(s) and save a record instance without triggering the hooks: after_save, after_create, after_update? I know it''s possible with Record.update() but this is dynamic. Only receive the instance, without knowing its class (thus cannot call the class method update()). Or is there a way of knowing the class and calling the class method? Thank you. -- Posted via
2008 Apr 22
1
graphics::Axis loosing S3/S4 class attributes of 'x' in 2.7.0 RC
Following my previous post on S3 method despatch, I put debug messages in the code of Axis, Axis.default and plot.default in graphics/R/axis.R and graphics/R/plot.R to print the class of x, at and y on plot. After recompiling R, what I see is that x *lost* its class attribute (at least for classes not known to 'graphics') in Axis, called directly from plot.default and this could be the
2006 Mar 21
2
Sorting by computed temporary field
Hey all, I''m rather new to Ruby and Rails (and not great with SQL), but I''m developing a ride sharing app and would like to be able to sort on something I don''t have stored. I have users, events, and rides, each of which has a zip code. Events have_many rides, and rides belong_to events. When an event is selected, I''d like to be able to show a list of
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
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 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 Jun 01
0
Disabling an after_save() in a rake conversion?
Hi all - I''ve got a model Foo that has an after_save() method. I''d like to disable it while doing a rake conversion. Seems I should be able to just redeclare Foo.after_save() somehow, but I''m not quite sure how to do that in the rake task... Any ideas? Thanks! -philip
2009 May 28
1
:has_many and :after_save
Having one to many connection (for example post has many comments), what is the most efficient way of saving all comments when post is saved. Using after_save on Post would introduce the n+1 problem. Is there any way of saving the whole structure at once? -- Posted via http://www.ruby-forum.com/.
2007 Feb 05
0
after_save and associations
It appears that when after_save is triggered, associations such as habtm haven''t been populated yet. Each association can have an :after_add callback, but my code needs to access multiple associations. Is there an explicit reason why after_save isn''t triggered after all of the associations have been populated? --~--~---------~--~----~------------~-------~--~----~ You received
2006 Mar 21
0
does after_save get called if failed save?
does after_save get called if failed save? Thanks, Chris -- Posted via http://www.ruby-forum.com/.
2012 Jan 28
2
after_save in plugin
Dear list, I am trying to override an after_save callback declared in main app using plugin. The main model class is: class WorkHours < ActiveRecord::Base @after_save_call_back_called=0 after_save :after_save_call_back def after_save_call_back logger.debug "after save called" @after_save_call_back_called=1 end end And in my plugin (in the lib directory) : module
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 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 Aug 11
1
after_initialize and after_save
Hello, I am still reading Agile Web Developer pdf, it says about after_initialize and after_find. There is a Joe asks part when I read that they are special, however I didn''t really get the idea, why they are. On rubyonrails.org in the manual there is some sort description about their speciality, however their full descriptions are missing. What are the difference between
2004 Feb 26
2
Trivial API question
I know - I like to futz. I''m thinking of changing the way I pass optional arguments. This is from EventLog: # Write an event to the event log # Current way el.report_event( "source" => "foo", "category" => 0x2, "event_id" => 0x3, "data" => "Warning! Danger Will Robinson!", "type"
2006 May 21
6
Possible problems with EventLog#write
Hi, I''ve got EventLog#write and EventLog.add_event_source methods done. Well, I *think* they''re done, but I can''t get the data (text) to work properly, and I''m not sure if it''s a bug in my .mc file, the add_event_source method, the write method, or just a goof in my test file. The source, category and event id seem to be ok. However, the
2007 Jun 28
1
complete stumper: variable exists in hidden_field_tag, but nil everywhere else
This is a real mystery to me. I have an instance variable in a partial that only gives its value inside a hidden_field_tag. If I try to use the variable anywhere else in the partial, i either get nil or an undefined error. The goal is to use the value of @event.id outside of hidden_field_tag. Here''s what works: <%= hidden_field_tag ''id'', @event && @event.id,
2006 Apr 22
4
Anyone know how to copy rows?
Hey all, I''m trying to write something that allows one to copy several rows from a table and create new rows based on those rows. This will be used to intentionally duplicate rows. Did I mention that I was having little luck? I''m from a PHP world, but I''ve been getting really into Rails lately. Here''s what I''ve got(assume an event has_many
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