在我的模型中,我想检查应用程序是在IRB控制台中运行还是作为网站运行?
class MyModel < ActiveRecord::Base
def xmethod
if !isIRBconsol
self.user_id = UserSession.find.user.id
end
end
end
在我的模型中,我想检查应用程序是在IRB控制台中运行还是作为网站运行?
class MyModel < ActiveRecord::Base
def xmethod
if !isIRBconsol
self.user_id = UserSession.find.user.id
end
end
end
if defined?(IRB)
?Rails.const_defined?('Console')
。 - toupeiraclass MyModel < ActiveRecord::Base
def am_i_in_irb?
self.private_methods.include? 'irb_binding'
end
end
unless self.private_methods.include? 'irb_binding'
#put your rufus scheduling here
end