Questions tagged [after-save]

68 questions
0
votes
1 answer

Updating a belongs_to model after_save

I have a User model that has_many :comments and a Comment model that belongs_to :user. I have want to gather comment.ratings to set user.rating so I have an after_save method in my Comment model that I call. However this never gets called. Here is…
eytanfb
  • 443
  • 4
  • 17
0
votes
2 answers

Rails 3.2 update attribute after save

I want to update an specific attribut in my database after save data. For example i have an column in my table which called pending and it's an boolean. i want to set this value to true when data was saved. after_save :do_something private def…
pkberlin
  • 812
  • 1
  • 13
  • 31
0
votes
2 answers

Complex After save association in ruby on rails

Theory :- after create of a record in customer bill, i am sending two sets of data two different models. one set of data is sent to ledger and one set of data is sent to ledger_line_item. the complexity is that after sending of data i want the…
0
votes
2 answers

cakephp how do you call a controller's action inside a model

I'm working within afterSave in my messages model. I'd like to send an email every time a message is created to notify the recepient of their new message. I have an action inside of the messages controller that sends the email and i'd like to call…
okwme
  • 740
  • 1
  • 7
  • 19
0
votes
1 answer

Rails 3: Model After Filter causing infinite loop

I have the following After Filters: User Model: def check_for_custom_district unless self.custom_district.blank? district = District.new(:name => custom_district, :state_id => state_id, :school_type_id => school_type_id) if…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
1 answer

How to set path where to save CSV file?

I'm saving records into CSV using after_save_filer. I don't receive any error and also I can't find file, what was generated(if it exists). Here is code what I'm using: after_save :to_csv def to_csv(options = {}) require 'csv' …
MID
  • 1,815
  • 4
  • 29
  • 40
-1
votes
2 answers

Determine what ids were removed from array in Rails after_save callback?

I am trying to figure out how i can tell what has changed in an array in the after save callback. Here is an example of code i am using: class User < ActiveRecord::Base has_many :user_maps, :dependent => :destroy has_many :subusers, :through =>…
NineBlindEyes
  • 579
  • 8
  • 18
-1
votes
1 answer

How to sum JSON objects data in Rails using after_save?

I'm storing daily orders inside daily_orders table. Inside that table, I've total column and special_kitchen_orders column (type: JSON). Right now, when I run this into my console: ap DailyOrder.first.special_kitchen_orders I get this back: [ …
Zulhilmi Zainudin
  • 9,017
  • 12
  • 62
  • 98
1 2 3 4
5