0

I have a two mailers

welcome_manger(user)  welcome_participant(user)

Both send different information and have different layouts.

when I call the deliver method I would like to use something like the following

UserMailer.welcome_self.role(self.user)

This does not work. How can I accomplish this?

1 Answer 1

2

Something like this perhaps:

m = 'welcome_' + self.role
UserMailer.send(m.to_sym, [self.user])

Assuming that self.role returns a String.

The send method invokes a method by name:

obj.send(symbol [, args...]) → obj
Invokes the method identified by symbol, passing it any arguments specified.

So you just need to build the appropriate method name as a string and then convert it a symbol with to_sym.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.