padrino / padrino-framework

Padrino is a full-stack ruby framework built upon Sinatra.
http://www.padrinorb.com
MIT License
3.37k stars 508 forks source link

SubApps not finding routes #1917

Closed ianseyer closed 9 years ago

ianseyer commented 9 years ago

I have a three apps loaded under one main app, in a project called SnapStories: Reports, Organization, and Auth. They were created & mounted via the padrino generators.

However, rake routes yields nothing: no errors or routes. The only routes that actually get served are those in app/app.rb. Nothing from my controllers in my subapps.

Code here: https://github.com/ianseyer/snapstories-public

namusyaka commented 9 years ago

@ianseyer Thanks for the clear explanation. I'd like to tell you two points:

  1. rake routes outputs only named routes, so you must define the named route.
# before
get "/" do
end

get "/foo" do
end

# after
get :index do
end

get :foo do
end
  1. The order of sub application defined in your apps.rb is incorrect. The main application should be placed in the end.
Padrino.mount('SnapStories::Auth', :app_file => Padrino.root('auth/app.rb')).to('/auth')
Padrino.mount('SnapStories::App', :app_file => Padrino.root('app/app.rb')).to('/')

See: Upgrading Padrino from 0.11.X to 0.12.0 Guide's Reorder Mounter Apps section.

ianseyer commented 9 years ago

Thank you!