Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

index pages #27

Closed
wants to merge 2 commits into from

3 participants

ludicast Matt Jankowski Mike Burns
ludicast

To help with breadcrumbs etc., I added an option for index pages. Say you visit e.g.

/pages/my_category

If high_voltage fails to locate the my_category.html view, the controller will also check:

/app/views/pages/my_category/index.html.erb

Matt Jankowski
Admin

I'm not opposed to something like this, just want to clarify the intention -- can you outline the use case where this functionality is useful?

ludicast

When it comes down to it, it's really just for the aesthetics of high_voltage matching the way rails and webservers typically behave (i.e. with the resource at /users rendering /users/index.html.haml or /documentation serving /documentation/index.php).

I won't be too insulted if you don't accept the pull request though, as it is a minor feature.

Mike Burns
Admin

We've decided that, since we won't make use of this feature, it's best left out.

Thank you for the patch, though!
-Mike

Mike Burns mike-burns closed this
ludicast

No problem. Might as well keep HV lean and mean!

Matt Jankowski
Admin

It's the meanest!

Odin Dutton twe4ked referenced this pull request
Closed

Fallback to index #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 25, 2011
  1. ludicast

    added fallback for index page

    ludicast authored
  2. ludicast

    added spec for index page

    ludicast authored
This page is out of date. Refresh to see the latest.
8 app/controllers/high_voltage/pages_controller.rb
View
@@ -5,8 +5,12 @@ class HighVoltage::PagesController < ApplicationController
rescue_from ActionView::MissingTemplate do |exception|
if exception.message =~ %r{Missing template #{HighVoltage::content_path}}
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
- else
+ begin
+ render :template => "#{current_page}/index", :layout => HighVoltage::layout
+ rescue ActionView::MissingTemplate => e
+ raise ActionController::RoutingError, "No such page: #{params[:id]}"
+ end
+ else
raise exception
end
end
9 spec/controllers/pages_controller_spec.rb
View
@@ -28,6 +28,15 @@
end
end
+ describe "on GET to /pages/dir" do
+ before { get :show, :id => 'dir' }
+
+ it "should respond with success and render index template" do
+ response.should be_success
+ response.should render_template('pages/dir/index')
+ end
+ end
+
it "should raise a routing error for an invalid page" do
lambda { get :show, :id => "invalid" }.should raise_error(ActionController::RoutingError)
end
1  spec/dummy/app/views/pages/dir/index.html.erb
View
@@ -0,0 +1 @@
+hello <%= 'world' %> from index page
Something went wrong with that request. Please try again.