Static pages from Rails erb templates?

51 views
Skip to first unread message

gvim

unread,
Nov 2, 2015, 9:03:15 AM11/2/15
to rubyonra...@googlegroups.com
Is there a way to have static content generated from Rails templates
without going through the empty controller nonesense? Sometimes a site,
especially an old one, has lost of static content and a few forms where
only the forms need to be handled by Rails but it is necessary for Rails
to use the same templates as required by the static content.

gvim

Scott Eisenberg

unread,
Nov 2, 2015, 9:07:27 AM11/2/15
to rubyonra...@googlegroups.com
Maybe high voltage gem will work for you.


On Nov 2, 2015, at 9:01 AM, gvim <gvi...@gmail.com> wrote:

Is there a way to have static content generated from Rails templates without going through the empty controller nonesense? Sometimes a site, especially an old one, has lost of static content and a few forms where only the forms need to be handled by Rails but it is necessary for Rails to use the same templates as required by the static content.

gvim

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56376CBD.1000401%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

gvim

unread,
Nov 3, 2015, 9:17:24 AM11/3/15
to rubyonra...@googlegroups.com
On 02/11/2015 14:06, Scott Eisenberg wrote:
> Maybe high voltage gem will work for you.
>
> https://github.com/thoughtbot/high_voltage
>

At first glance this looks way over-complicated for what I had in mind.
I would like to have the option to run some kind of rake task which can
identify erb templates for static generation and publish them to the
public directory. I could simply use Middleman but then I have to keep
my templates and assets in sync with my Rails templates so not ideal.

gvim

Scott

unread,
Nov 4, 2015, 10:42:33 AM11/4/15
to Ruby on Rails: Talk
It's not complicated. Install the gem. Create a directory. Use page_path route with the file name to generate links. I'm not sure how you get simpler than that.

If you want a non rails way, put the pages in the public directory.

Seems like you could have been finished with either high voltage or public in the time it took you to publish another comment.

Colin Law

unread,
Nov 4, 2015, 10:47:29 AM11/4/15
to Ruby on Rails: Talk
On 4 November 2015 at 15:28, Scott <rscotte...@gmail.com> wrote:
> It's not complicated. Install the gem. Create a directory. Use page_path route with the file name to generate links. I'm not sure how you get simpler than that.
>
> If you want a non rails way, put the pages in the public directory.

Can one use erb in the public directory?

Colin

Scott

unread,
Nov 4, 2015, 10:53:47 AM11/4/15
to Ruby on Rails: Talk
Please ignore the snarky comment at the end of the last comment and the stuff about just or putting in the public directory. I re-read your comment on Middleman and got a better feeling for what you are trying to do.

The snark was me being out of my mind.

Back on topic how dynamic is the erb you have? Are there models to go through? Are the links hard coded or generated from link_to statements? Maybe some sample pages would be helpful to offer suggestions.

Scott

unread,
Nov 4, 2015, 10:56:02 AM11/4/15
to Ruby on Rails: Talk
I don't think you can use erb in public. I don't think they'd be parsed to html outside of the app area.

Colin Law

unread,
Nov 4, 2015, 11:43:42 AM11/4/15
to Ruby on Rails: Talk
On 4 November 2015 at 15:56, Scott <rscotte...@gmail.com> wrote:
> I don't think you can use erb in public. I don't think they'd be parsed to html outside of the app area.

That's what I thought.

Colin

gvim

unread,
Nov 4, 2015, 12:45:44 PM11/4/15
to rubyonra...@googlegroups.com
It's just basic headers and footers really with <title> dynamic. I'm
moving a Perl CGI::Application app to Rails. Most of the files are
static and were generated with Perl Template::Toolkit. The company is
looking to do bigger things so I thought I'd port everything to Rails in
preparation. Rails will just handle the forms for now. Didn't like the
way Middleman seems to require a duplicate copy of all the assets.

gvim
Reply all
Reply to author
Forward
0 new messages