Questions tagged [after-save]
68 questions
0
votes
1 answer
Rails - Trying to flip an active flag in children associations
I have two models, Forums and Topics, Forums has many Topics. Each has an active boolean. When I flip the active flag on a Forum, I want its Topics to all get their flag flipped as well. My thought was to do this in a before_save
def…

Chip
- 1,653
- 2
- 20
- 27
0
votes
1 answer
after_save callback with virtual attributes Rails 3
I don't know if this is possible so I thought I would ask.
1. Give a model some virtual attributes
2. Assign values to the model and the virtual attributes
3. Save the model
4. Use a callback after_save to create a different object with the virtual…

chell
- 7,646
- 16
- 74
- 140
0
votes
1 answer
Using after_save to update all belongs_to records
I'm building a project management application in Ruby on Rails (3.0). I am trying to figure out how to update all the tasks of a project on update of a project column. Here is the situation.
I am listing all the projects, as expected, in…

bgadoci
- 6,363
- 17
- 64
- 91
0
votes
1 answer
SugarCRM identify if the record is created or updated from after_save hook
I have a SugarCRM 6.5 application. I have to trigger an email using after_save hook when a record is created(not during update).
I know I can use the workflow. But I can't use the workflow for this scenario due to multiple reasons.
Now I need to…

siddiq
- 1,693
- 3
- 17
- 44
0
votes
1 answer
Ruby MongoId: race condition in callbacks
I have the Model:
class MyModel
include Mongoid::Document
after_save :my_callback, if: -> { name_changed? }
field :name, type: String
def my_callback
# this will execute two times
puts 'executes my callback'
…

Armando
- 603
- 1
- 5
- 14
0
votes
1 answer
Rails callback for after insert
I'm using a closure table to model the hierarchical structure of one of my models. As such, I am using an after_create hook to create the tree_path objects whenever Model.create is called. I would also like this hook to run whenever #new is called…

C-RAD
- 1,052
- 9
- 18
0
votes
1 answer
Run a macro after saving excel-file won't work
I can't get my macro running in AfterSave or BeforeClose event.
I export one sheet to a .csv file, that's already working well with the next code when I link this macro to a button:
Sub…

Danny1991
- 3
- 1
- 4
0
votes
3 answers
Ruby on Rails -- Stack level too deep
model:
after_save :set_correct_post_type
def set_correct_post_type
if self.document.present?
if (find_mime_type(self.document.original_filename) == "application/vnd.openxmlformats-officedocument.presentationml.presentation") ||…

R.lOOp
- 15
- 7
0
votes
1 answer
deprecated after_save solution in rails 3
hi
I am create one application in rails 3 I am using paperclip in which i want to invoke one paperclip function for generate a thumbnail of image but when I invoke a after_save method it will give a error
DEPRECATION WARNING:…

hardik9045
- 499
- 1
- 6
- 17
0
votes
1 answer
Start method just once for addition / removal of association elements
I have a Composition model which has a has_and_belongs_to_many :authors.
I need to fire a method after a composition changed its authors, although, since it involves the creation of a PDF file (with the name of the authors), I want to call this…

Simon
- 701
- 6
- 25
0
votes
2 answers
How to catch when project is closed
Redmine's model Project has a method
def close
self_and_descendants.status(STATUS_ACTIVE).update_all :status => STATUS_CLOSED
end
In this method updating with update_all means that when projects are closed callback after_save is not…

Developer Marius Žilėnas
- 5,813
- 1
- 41
- 70
0
votes
1 answer
Parse Server - afterSave push on specific field change
I have job collection and it has a field applicants which is Relation type of class User. Now I want to send a push notification to a user when an operation like AddRelation or RemoveRelation happens on the applicants field. Parse Object has…

Faysal Ahmed
- 1,592
- 13
- 25
0
votes
1 answer
before insert and after delete
i am somehow lost again in my beginners project. I am adding records for flights which have a takeoff and a landing time. So everytime i am inserting a flight oder deleting it (to edit is another question) i would like to update the total airframe…

Christian Waschke
- 31
- 8
0
votes
1 answer
Why is afterSave() inside app_model.php always fires?
Why is afterSave() inside app_model.php always triggering on every page load?
class AppModel extends Model
{
public $cacheQueries = true;
var $actsAs = array('Containable');
function __construct($id = false, $table = null, $ds =…

steamboy
- 1,162
- 5
- 20
- 37
0
votes
1 answer
Is it possible to do an aftersave() on an app_controller.php in CakePHP?
Is it possible to do an aftersave() on an app_controller.php in CakePHP?
I want to detect this on the app_controller for global use so I won't redo it on each controller or model.
Thanks,
S

steamboy
- 1,162
- 5
- 20
- 37