# Best way to generate static pages

**URL:** <https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820>\
**Category:** Rails\
**Created:** [February 3, 2010, 8:58am UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820 "2010-02-03T08:58:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 8:58am UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/1 "2010-02-03T08:58:53Z")

</div>

hi, guys  
I tried using Thoughtbot’s High-Voltage to generate static pages in  
my app. For some reason, I can’t seem to make it work cause it keeps  
redirecting to one of my search pages. Anyway, I can’t seem to find  
more info in the documentation of high-voltage. There was some mention  
of “danger” in the docs but that’s about it.

I have googled on how to generate static pages using rails but can’t  
find anything useful.

I guess for the moment, i will have to create a controller (named  
after the static resource, “about\_us”) followed by a corresponding  
file in the view.

Anyway, can anyone share a good way of generating static pages?

Thanks!

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 3:21pm UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/2 "2010-02-03T15:21:43Z")

</div>

ct9a wrote:

> hi, guys  
> I tried using Thoughtbot’s High-Voltage to generate static pages in  
> my app. For some reason, I can’t seem to make it work cause it keeps  
> redirecting to one of my search pages. Anyway, I can’t seem to find  
> more info in the documentation of high-voltage. There was some mention  
> of “danger” in the docs but that’s about it.
> 
> I have googled on how to generate static pages using rails but can’t  
> find anything useful.

If they’re static, don’t generate them with Rails. Rails is only for  
generating dynamic pages.

> I guess for the moment, i will have to create a controller (named  
> after the static resource, “about\_us”) followed by a corresponding  
> file in the view.

No controller needed. Just put the static stuff in the public  
directory.

> Anyway, can anyone share a good way of generating static pages?

If you really want to _generate_ static pages, try StaticMatic. But I  
don’t think that’s what you actually meant.

> Thanks!

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 3:36pm UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/3 "2010-02-03T15:36:20Z")

</div>

Ryan B. (railscasts) also has an episode on the subject:

> **[\#117 Semi-Static Pages - RailsCasts](http://railscasts.com/episodes/117-semi-static-pages)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 7:20pm UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/4 "2010-02-03T19:20:29Z")

</div>

On Feb 3, 2:57 am, ct9a [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I tried using Thoughtbot’s High-Voltage to generate static pages in  
> my app. For some reason, I can’t seem to make it work cause it keeps  
> redirecting to one of my search pages. Anyway, I can’t seem to find  
> more info in the documentation of high-voltage. There was some mention  
> of “danger” in the docs but that’s about it.

The “Danger” reference in the docs is a joke, referring to the name of  
the engine, which is named after the song “High Voltage” by the  
Electric Six:

[![](https://i.ytimg.com/vi/HD5tnb2RBYg/hqdefault.jpg "Electric Six - Danger! High Voltage!") ](https://www.youtube.com/watch?v=HD5tnb2RBYg)

You do not create a controller (part of the reason for using it).

You should be able to:

link\_to “About Us”, page\_path(“about\_us”)

What is your search page’s route? What is your output when running  
“rake routes”?

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 7:20pm UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/5 "2010-02-03T19:20:29Z")

</div>

What kind of problems are you seeing? Maybe you set it up wrong, have  
you seen [High Voltage](http://robots.thoughtbot.com/post/160768450/high-voltage) ?  
Perhaps paste your routes.rb or `rake routes` and that could help too.

-Nick

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 3, 2010, 10:48pm UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/6 "2010-02-03T22:48:57Z")

</div>

hi, Marnen 🙂

StaticMatic - sounds interesting. Will google and read.

Cheers 🙂

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 4, 2010, 1:38am UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/7 "2010-02-04T01:38:39Z")

</div>

hi Dan,  
thanks for the explaination. Finally clicked LOL

Alas, i have remove the code that used it but i will go back to git  
and see what i can do.  
Cheers, Dan!

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 4, 2010, 1:43am UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/8 "2010-02-04T01:43:55Z")

</div>

hey, Dan,

Any intention to offer high voltage as a gem?

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [February 4, 2010, 2:57am UTC](https://www.ruby-forum.com/t/best-way-to-generate-static-pages/182820/9 "2010-02-04T02:57:04Z")

</div>

# 1)routes.rb

ActionController::Routing::Routes.draw do |map|  
map.resources :parts, :has\_many =\> :images  
map.resources :parts, :has\_many =\> :fits  
map.set\_primary\_image ‘parts/:part\_id/images/:id/  
primary’, :controller =\> ‘images’, :action =\> ‘set\_as\_primary’  
map.resources :brands  
map.resources :makes, :has\_many =\> :vehicles  
map.resources :categories, :has\_many =\> :sub\_categories  
map.resource :account, :controller =\> “users”, :has\_one =\>  
‘address’  
map.resource :user\_session  
map.search\_form ‘/search\_form’, :controller =\> ‘search’, :action =\>  
‘form’  
map.search ‘/search’, :controller =\> ‘search’, :action =\>  
‘perform\_search’  
map.root :controller =\> “home”  
end

# 2)Extract of “rakes”

\<---------- Extract start --------------------\>  
(in /home/ct9a/projects/myApp)  
search\_form /  
search\_form  
{:controller=\>“search”, :action=\>“form”}  
search /  
search  
{:controller=\>“search”, :action=\>“perform\_search”}

root /  
{:controller=\>“home”, :action=\>“index”}

```
       ...
                  page GET /

```

pages/:id(.:format)  
{:controller=\>“high\_voltage/pages”, :action=\>“show”}  
Showing all Routes

- /pages/:id(.:format)?  
\<---------- Extract end --------------------\>

1. Error message  
================

Error message on webbrowser as soon as I open up: “[http://sample.com/](http://sample.com/)  
pages/tester”

\<---------- Extract start --------------------\>  
ActionController::RoutingError in High\_voltage/pages#show

Showing app/views/search/\_keyword\_form.erb where line #1 raised:

No route matches  
{:action=\>“perform\_search”, :controller=\>“high\_voltage/search”}

Extracted source (around line #1):

1: \<% form\_for :search, :url =\> { :action =\>  
“perform\_search”, :controller =\> “search” }, :html =\> {:method =\>  
“get”} do |f| %\>  
2:

3:   
4: \<%= f.submit ‘Search’ %\>

\<---------- Extract end --------------------\>

For some weird reason, I do not know why the search controller is  
being invoked…
