before-save Questions
4
Solved
I'm trying to get the old value in the before_save by adding "_was" to my value but it doesn't seem to work.
Here is my code:
before_save :get_old_title
def get_old_title
puts "old value #{self...
Coleencolella asked 6/4, 2015 at 4:38
5
Solved
I'm trying to compare a new object with the original using CloudCode beforeSave function. I need to compare a field sent in the update with the existing value. The problem is that I can't fetch the...
Gast asked 2/10, 2015 at 20:0
5
Solved
I have a before_save in my Message model defined like this:
class Message < ActiveRecord::Base
before_save lambda { foo(publisher); bar }
end
When I do:
my_message.update_attributes(:cre...
Lucifer asked 30/8, 2011 at 13:15
4
Solved
I am raising a Yii event on beforeSave of the model, which should only be fired if a specific property of the model is changed.
The only way I can think of how to do this at the moment is by creat...
Cao asked 27/8, 2013 at 9:16
2
Solved
I have two different calculations to make on my model for two different fields. Before saving.
Class Event < ActiveRecord::Base
#some relations
before_save :method1, unless: :some_field_1?
b...
Reganregard asked 20/3, 2015 at 14:48
2
Solved
I'm trying to strip the whitespaces of the variable Username in my User Model.
I'm using
before_save do
self.username.strip!
end
but it doesn't seem to work, am i missing something ?
Goodsell asked 28/1, 2014 at 9:9
1
Solved
As you know, before_save callbacks are executed prior to before_create callbacks.
Therefore, some people have suggested that in would be better to use before_save :method, :on => :create instea...
Boatbill asked 17/5, 2012 at 17:6
1
Whats wrong with this before_save-callback?
class Order < ActiveRecord::Base
has_many :line_items, :dependent => :destroy, :inverse_of => :order
accepts_nested_attributes_for :line_ite...
Rogan asked 11/11, 2011 at 22:30
1
Solved
I want to check if a model is being created in the before_save callback of Rails.
I also want to check if it has been modified (when updating).
Thanks
Propagandist asked 26/12, 2011 at 19:8
1
© 2022 - 2024 — McMap. All rights reserved.