Home how to call action from model to controller in ruby on rails
Reply: 0

how to call action from model to controller in ruby on rails

user7388 Published in September 20, 2018, 12:48 pm

I am trying to call 'checking' action from post model.

class Post < ApplicationRecord
     after_commit :testing
     def testing
         @id = "#{self.id}"
         puts @id
         checking # call action to controller 


def checking
  puts "not Working"

I am trying to achieve the above, whereas it is not getting called.

share|improve this question
  • you should be calling model functions from controller, models should not be aware of controller logics – Subash Feb 13 at 10:22
  • 1
    What is the reason your doing that? Explain more what are really what to do, because it seems that you are just lost. – araratan Feb 13 at 10:27
  • The models should not know about the controller logic. Maybe you can refactor and set some variables from controller to model like it is described in this thread – mmsilviu Feb 13 at 12:07
  • What exactly you want? Why you exactly need to call a controller? – Manishh Feb 13 at 12:20

4 Answers 4

active oldest votes
up vote -1 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311838 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO