Hello Friends,
I am using rspec for testing my model, and I have used callbacks in my model
as things are working as expected on the front end. but when I try to test
the application it throws an error.
My code.
*
*
class MyModel < ActiveRecord::Base
after_create CreateProfileCallBacks
end
-----------------------------------------
class CreateProfileCallBacks
def self.after_create(args)
my_code
end
end
And when I run the spec getting the following error.
*Callbacks must be a symbol denoting the method to call, a string to be
evaluated, a block to be invoked, or an object responding to the callback
method.*
And I already Googled it But no success, it will be really helpful if I get
any Clue on the above mentioned error.
--
Thanks
Abhis
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Friends any clue still struggling. :( On Thu, Jul 29, 2010 at 6:04 PM, Abhishek shukla <betterabhi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hello Friends, > I am using rspec for testing my model, and I have used callbacks in my > model as things are working as expected on the front end. but when I try to > test the application it throws an error. > > My code. > > * > * > class MyModel < ActiveRecord::Base > after_create CreateProfileCallBacks > end > > ----------------------------------------- > > class CreateProfileCallBacks > def self.after_create(args) > my_code > end > end > > And when I run the spec getting the following error. > *Callbacks must be a symbol denoting the method to call, a string to be > evaluated, a block to be invoked, or an object responding to the callback > method.* > > And I already Googled it But no success, it will be really helpful if I get > any Clue on the above mentioned error. > > -- > Thanks > Abhis >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
anObjectNotAmethodStringOrBlock=CreateProfileCallBacks.new On Thu, Jul 29, 2010 at 10:27 PM, Abhishek shukla <betterabhi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Friends any clue still struggling. :( > > On Thu, Jul 29, 2010 at 6:04 PM, Abhishek shukla <betterabhi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Hello Friends, >> I am using rspec for testing my model, and I have used callbacks in my >> model as things are working as expected on the front end. but when I try to >> test the application it throws an error. >> >> My code. >> >> * >> * >> class MyModel < ActiveRecord::Base >> after_create CreateProfileCallBacks >> end >> >> ----------------------------------------- >> >> class CreateProfileCallBacks >> def self.after_create(args) >> my_code >> end >> end >> >> And when I run the spec getting the following error. >> *Callbacks must be a symbol denoting the method to call, a string to be >> evaluated, a block to be invoked, or an object responding to the callback >> method.* >> >> And I already Googled it But no success, it will be really helpful if I >> get any Clue on the above mentioned error. >> >> -- >> Thanks >> Abhis >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey Abhi, I think you try evaluating the code directly as a string,
eg: before_destroy ''self.class.delete_all "parent_id =
#{id}"''
Hope this helps.
Aashish
On Jul 30, 10:27 am, Abhishek shukla
<bettera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Friends any clue still struggling. :(
>
> On Thu, Jul 29, 2010 at 6:04 PM, Abhishek shukla
<bettera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:
>
> > Hello Friends,
> > I am using rspec for testing my model, and I have used callbacks in my
> > model as things are working as expected on the front end. but when I
try to
> > test the application it throws an error.
>
> > My code.
>
> > *
> > *
> > class MyModel < ActiveRecord::Base
> > after_create CreateProfileCallBacks
> > end
>
> > -----------------------------------------
>
> > class CreateProfileCallBacks
> > def self.after_create(args)
> > my_code
> > end
> > end
>
> > And when I run the spec getting the following error.
> > *Callbacks must be a symbol denoting the method to call, a string to
be
> > evaluated, a block to be invoked, or an object responding to the
callback
> > method.*
>
> > And I already Googled it But no success, it will be really helpful if
I get
> > any Clue on the above mentioned error.
>
> > --
> > Thanks
> > Abhis
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.