In my model, I would like to check if the application works inside the IRB console or as a website?
class MyModel < ActiveRecord::Base def xmethod if !isIRBconsol self.user_id = UserSession.find.user.id end end end
This is a bit hacky, but it should work:
class MyModel < ActiveRecord::Base def am_i_in_irb? self.private_methods.include? 'irb_binding' end end
But, as Katy Van Stone said, this is probably what has the best solution.
Why not easy if defined?(IRB)?
if defined?(IRB)
unless self.private_methods.include? 'irb_binding' #put your rufus scheduling here end