Generate HTML page using rails without a webserver

is possible to generate an HTML page using Ruby on Rails framework without using a webserver? I want do something like this:

html = RailsHTMLGenerator.generate('path/to/rails/root', '/posts/540')
puts html

The first parameter is the Rails.root, the second is the HTTP path, and the function return the HTML of that page as string.

Someone can tell me how to do this? Ty.


I've found a solution:

require '/path/to/application.rb'
app = APPName::Application.initialize!
session =
session.get '/'
puts session.body

Well, you can do that from the Rails console

app.get '/foo'

This is how the console is initialized in case you want to try this approach:

Need Your Help

True difference between 'normal' and 'inside-function' imports in Python

python import module globals locals

With respect to this question: local-import-statements-in-python, quoted here at the time of my asking:

Vertical alignment of text in Button in TableLayout

android android-button android-tablelayout text-alignment

I have a TableLayout full of Buttons (a grid of buttons), which may or may not have wrapped text. By default, the baseline of the first line of text is used as the vertical alignment point, so the