Skip to content

Commit

Permalink
expand docs to include alternate routing example, more reasons to ove…
Browse files Browse the repository at this point in the history
…rride controller, expanded override example with case based layout choosing
  • Loading branch information
mjankowski committed Dec 30, 2010
1 parent 71d9014 commit d06b998
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ After putting something interesting there, you can link to it from anywhere in y

link_to "About", page_path("about")

This will also work, if you like the more explicit style:

link_to "About", page_path(:id => "about")

Bam.

== Routes
Expand All @@ -52,7 +56,10 @@ Which will render a homepage from app/views/pages/home.html.erb

== Override

Most common reasons to override? Authentication, layouts.
Most common reasons to override?

* You need authentication around the pages to make sure a user is signed in.
* You need to render different layouts for different pages.

Create a PagesController of your own:

Expand All @@ -62,7 +69,17 @@ Then modify it to subclass from High Voltage, adding whatever you need:

class PagesController < HighVoltage::PagesController
before_filter :authenticate
layout "danger"
layout :layout_for_page

protected
def layout_for_page
case params[:id]
when 'home'
'home'
else
'application'
end
end
end

== Testing
Expand Down

0 comments on commit d06b998

Please sign in to comment.