Ruby on Rails Tuesday, March 29, 2011

Use google to search for: around_save yield


yield be inside the method around_save

Everything is before yield is before save the record
All is after yield is after save the record

def around_save
    #do anything before save
    yield
    # do anything after save
end

2011/3/29 Alexey M. <lists@ruby-forum.com>
Hello,
i am playing with some test application in console: creating a model,
saving it, changing its id, trying to save it again, changing the id
back, saving again, etc.
The results are sometimes unexpected, but maybe i just do not understand
how/when the records are saved.

Can anybody please tell me if calling the "save" method saves the model
immediately?
If not, what is the method to save it immediately?

I keep an Sqlite database browser open (a Firefox extension), and it
seems that some "save" calls have no effect, but after changing some
attributes, the "save" works again.
I wonder if it is because of my messing around with id, or just the data
base does not get updated immediately.

Thanks.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.




--
Rodrigo Mendonça
(62) 8567-3142

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment