Access a instance method from other model in ruby on rails? -


I have a user model in my application. Now I want to avoid more number of code in a model model, module Under the users 2 categories of potential employed and RBB and customers Want to change some user model coding in RBG After creating the user I want to use send_mail in a method in customer.rb.

user.rb

  after_create: send_msg_on_order def send_msg_on_order user :: customer. Send_mail end  

user / customer.rb

  def send_mail mailer. Send_mail_to_customer.deliver end  

and I'm getting an undefined method to 'send_mail' for user: Customer: module error.

You method in the form of the send_mail customer model and call it.

Make the method a class method:

  def self .send_mail Mailer.send_mail_to_customer.deliver end  

If you have an example Call it this way:

  after_create: send_msg_on_order def send_msg_on_order user :: customer.new.edememmail end  

hh


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -