I’m using Rails 3.0.6.
In my lib directory I have a example_app.rb, which is simply a Sinatra app:
class ExampleApp < Sinatra::Base
get '/' do
"Hello from Sinatra"
end
end
And I’m autoloading it with the application.rb config.auto_load_paths configuration.
In my routes file, I have only:
match "/" => ExampleApp
And that matches fine when I run the rails server (Webrick). However if I try:
match "/example" => ExampleApp
Visiting localhost:3000/example gives me a ‘No route matches “/example”‘ error. Running rake routes shows the route though:
example /example(.:format) {:to=>ExampleApp}
If I try and match ‘/example’ against a controller action it works fine, but not to that Sinatra app up above, so I’m not sure what’s going on. I know there’s something small I’m missing that I’m not finding in the routing documentation on the Rails site.
Thanks for any help.
The problem is that your Sinatra app only responds to requests made to
/. You need to either addor do a wildcard match using
*