similar to: Disabling an after_save() in a rake conversion?

Displaying 20 results from an estimated 40000 matches similar to: "Disabling an after_save() in a rake conversion?"

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
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
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 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 May 12
1
Running rake test:units yields DEPRECIATION WARNING: Disabling sessions for a single controller...
When I run my rake test:units I get the following: DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don''t access them, consider them off. You can still modify the session cookie options with request.session_options.. (called from C:/Users/Wayne/ Documents/Aptana Studio/chores/app/controllers/
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 May 09
2
Disabling FOREIGN KEYs in a Rake task
Hi, How could I disable my database FOREIGN KEYs in a Rake task? Or, how could I call the execute() method in a Rake task? I''m trying to perform something like: task :delete_the_cippalippa => :environment do require RAILS_ROOT+''/lib/marsian.rb'' # FIXME: execute() is undefined execute "SET FOREIGN_KEY_CHECKS = 0" Cippalippa.delete(-1)
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
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/.
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
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
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/.
2006 Dec 20
2
OSX Dashboard Widget for managing mongrels...
Hey everyone - I recently switched to using a Mac and have several different rails projects going and was getting tired of starting/stopping mongrels via the shell so wrote my first dashboard widget to do it for me. More details at the URL below... http://blog.pjkh.com/2006/12/20/mongrel-rails-dashboard-widget Hope those of you on OSX find it handy... feels good to finally give something
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
2006 May 11
0
Using action view helpers (strip_tags) in a rake task?
Hi all - I''ve got a rake task that migrates some old data (simple, loop through the old stuff, modify it a bit, and save it to the new system). That all works great. However, I''d like to use strip_tags() to remove all HTML from some of the fields I''m converting, but I can''t figure out how to include/use/require/load/etc the right stuff to make this work.
2006 Apr 25
2
DateTime format YYYY-MM-DDTHH:MM:SSZ ????
Hi all - Implementing my first web service with rails and trying things out using the "/controller/invoke" interface. Mostly works fine. But I have a function that takes a datetime and returns all rows that are newer than that. According to the log the SQL it''s generating is this: SELECT * FROM xxxx WHERE (created_at >= ''2006-04-25T13:18:31Z'') I have
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
2006 May 11
4
string to date/time?
Hey All, Anyone know of a library for parsing "human" dates, like "this friday" or "2 days ago"? I used to use strtotime in php, but starting from here; http://wiki.rubyonrails.com/rails/pages/PhpStrtotime and doing lots of googling, I haven''t been able to find anything similar for ruby. I know of javascript solutions to this, but I''d need to do
2010 May 28
3
Beginner Facing Problem with rake db:migrate
I am beginner for this Rails from the past 2 days I am working hard to fix the following error C:\Murali Rubby\demo\library>rake db:migrate --trace (in C:/Murali Rubby/demo/library) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == CreateBooks: migrating ==================================================== --