does a ruby on rails rack class get access to the entire rails environment?

Posted by Andrew Arrow on Stack Overflow See other posts from Stack Overflow or by Andrew Arrow
Published on 2013-06-26T21:50:05Z Indexed on 2013/06/27 16:21 UTC
Read the original article Hit count: 235

Filed under:
|
|

that is when the

def call(env)

method is invoked by hitting any url, can I inside that method make some ActiveRecord queries, use classes defined in lib, etc. etc.

Or is it more like an irb console without the rails env loaded? Another way to put it with a rake task example:

 task :foo => :environment do
    # with env
  end

 task :foo2 do
    # without env
  end

I would think rack classes would NOT get the environment so they are super fast and don't take all the overhead of a normal rails request.

But that doesn't seem to be the case. I CAN make ActiveRecord queries inside my rack class. So what is the advantage of rack then?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby