# After\_create callback in subclass

**URL:** <https://www.ruby-forum.com/t/after-create-callback-in-subclass/139372>\
**Category:** Rails\
**Created:** [June 3, 2008, 10:17am UTC](https://www.ruby-forum.com/t/after-create-callback-in-subclass/139372 "2008-06-03T10:17:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [June 3, 2008, 10:17am UTC](https://www.ruby-forum.com/t/after-create-callback-in-subclass/139372/1 "2008-06-03T10:17:00Z")

</div>

I have a User model with a protected method defined:

def set\_role(rolename)  
role = Role.find\_by\_rolename(rolename)  
permission = Permission.new  
permission.role = role  
permission.user = self  
permission.save(false)  
end

and a subclass with:

after\_create set\_role(‘client’)

This always fails for me with the error:

undefined method `set\_role’ for #Class:0x2798838

however, if I call it with a symbol:

after\_create :set\_role

it finds the method, but fails with a “wrong number of arguments” (as  
you would expect).

How can I call the method as a symbol and pass arguments at the same  
time?

thanks  
dorian

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [June 3, 2008, 10:27am UTC](https://www.ruby-forum.com/t/after-create-callback-in-subclass/139372/2 "2008-06-03T10:27:37Z")

</div>

ok, I just reread the activerecord docs and found the answe:

‘The callback macros usually accept a symbol for the method they‘re  
supposed to run, but you can also pass a “method string”, which will  
then be evaluated within the binding of the callback’

So I used after\_create ‘self.set\_role(“client”)’ and it worked fine.
