Re: after_save does not work consecutively

rubyonrailsx
Fri, 16 Mar 2012 05:24:16 -0000

Do know why fresh created video can create script but following video does not.
What i am 100% sure is that after_save is not right place to put this logic.
Cause any object''s update will invoke after save, so new script will
created every update.

--
rubyonrailsx
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Friday, March 16, 2012 at 1:16 PM, Soichi Ishida wrote:

> Rails 3.1.3
>
> Related to my old thread
>
> http://www.ruby-forum.com/topic/3802905#new
>
> video.rb has
>
> after_save :create_first_script
> private
> def create_first_script
> @script = Script.new(:video_id => self.id, :startp => 0, :text =>
> ''ToDo: '')
> @script.save
> end
>
>
> The problem is that after destroying all data, a freshly created video
> DOES create the first Script, but the following videos DO NOT.
>
> I have added User table so that Video and Script classes are only
> editable for Users that own them.
> The association is
>
> User:1 -- n:Video:1--n:Script
>
> To be honest, I have no idea which part of my code is causing this
> problem. I am sure the information provided here is not enough. I
> appreciate if you point out what I need to show you in order to gain
> some help.
>
> Thanks in advance.
>
> soichi
>
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
(mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org).
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
(mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org).
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>