Leonardo Mateo wrote: > On Fri, Nov 13, 2009 at 10:39 AM, Kalpesh1 Patel > <[email protected]> wrote: >>>> when callback method is called? >>> >>> Callbacks like before_create can't take any arguments >>> >>> Fred >> >> So isn't there any way I can pass some value from controller to model? > What do you mean? Of course you can pass values, in fact, you're > passing a value there. > I don't see the need of doing something like the before_create hook. > Why don't you just pass the value to the constructor? Simple.new(:name > => params[:simple]) > > > -- > Leonardo Mateo. > There's no place like ~
I need before_create because I want to do some preprocessing everytime i save my 'Simple' state in the DB. For example, authentication, logging or similar stuff I will perform just before 'save'(this might raise another question, is this right approach? but this can be a separate discussion). I thought of passing the value in the callback method itself but now I am able to do it through attr_accessor. Thanks Leo for the suggestion :) -Kalpesh -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

