dewski / kss-rails

A rails engine for @kneath's KSS documentation
MIT License
151 stars 39 forks source link

“Routing Error: No route matches” #4

Open alanhogan opened 12 years ago

alanhogan commented 12 years ago

After adding the kss-rails gem and running rails generate kss:install, I can see the KSS line was added to my routes, but going to /kss (and as far as I can tell, only URLs that start with /kss) results in this error:

Routing Error

   No route matches {:controller=>"statements"}

Try running rake routes for more information on available routes.

We do have a StatementsController, and it is in fact reachable (still), though the URL isn’t /statements.

Is KSS trying to do something special with our existing routes or controllers?

What might be causing this error?

alanhogan commented 12 years ago

Hmm. Resolved this.

The issue was that I had a before_filter on ApplicationController that was trying to use our app’s routing helpers like statements_path – but apparently since it was executing in the KSS app context, that wasn’t working.

It should have been a helper, anyway, so that’s how I resolved it.

tylerwolff commented 11 years ago

Not sure if this is related, but is there any way to have other routes other than home_path/styleguide. For instance if I set my root kss url to styleguide, can I create styleguide/buttons, styleguide/forms, etc? Anyone have experience doing something like this with the gem?

dewski commented 11 years ago

You should be able to do something like this (although untested):

In config/routes.rb:

Some::Application.routes.draw do
  get '/styleguide_path/buttons' => 'styleguide#buttons'
end

In app/controllers/styleguide_controller.rb

class StyleguideController < Kss::ApplicationController
  def buttons
  end
end

You can always fork the project and add as many routes and actions as you like and just point to the repo in your Gemfile.

gem 'kss-rails', :github => 'username/kss-rails'