How do I tell if rails is running under a web server, as opposed to a script or irb?
For context: I'm tracking an ActiveRecord object, and I want to email alerts if the objects changes, but only if the changes came through the web interface.
How do I tell if rails is running under a web server, as opposed to a script or irb?
For context: I'm tracking an ActiveRecord object, and I want to email alerts if the objects changes, but only if the changes came through the web interface.
Perhaps I'm missing something obvious but isn't the fact that if your model access occurs through a controller interface (i.e. some action) then, by definition, an access through a web interface?
Rails doesn't run under irb. Yes, you can access objects and state under the console
but that's not a web server access.
I think you just need to set up some filters in your controllers to implement your tracking logic for the models of interest and then you can differentiate between general access and web-server access (which is controller initiated).
Make sense?
I've found something that works, though it's not very pretty
$0 # => "irb" (for script/console)
# => "/some/handler.fcgi" (for webserver)
# => "/some/script.rb" (for a script)