Rails 3.2/4: Is there a way to easily render a template (partial, whatever...) from the console?

251 Views Asked by At

I've been looking for an easy way to render views (or templates). I've only seen complicated solutions all over the internet that involve getting the rendering engine, passing the context, which is normally an action view instance initialized with the original view paths, which are fetched from ActionController::Base, and then I can finally pass the local variables, this of course, if I am not using any instance variables inside the templates or I'm not using helper methods, for which I have to insert/include everything by hand, and then I still have some problems regarding relative location of partials, which are not infered outside the rails context.. uhf... Isn't there a main object I can call a simple #render method from?

1

There are 1 best solutions below

4
On

If you're working from the Rails console, you could call:

> app.get '/'
> response = app.response
> body = response.body