Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug into middleware? #10

Closed
seivan opened this issue Dec 13, 2010 · 5 comments
Closed

Plug into middleware? #10

seivan opened this issue Dec 13, 2010 · 5 comments

Comments

@seivan
Copy link

seivan commented Dec 13, 2010

How would one go through to plug this into middleware without using the Rails 3 routes?
Because using the routes would put it at th bottom of the stack.
Would save me time from implementing my own dsl... again.

@benschwarz
Copy link

You don't need to use rails3 routes. Grape is a rack application and should be loaded alongside your rails application.

Stick something like this in your config.ru

run Rack::Cascade.new([
   YourAppname::Application,
   YourAppname::API
])

@seivan
Copy link
Author

seivan commented Dec 13, 2010

Cool, how would that work with using models and helpers and how would the routes look like?

@benschwarz
Copy link

Forget routes!

This is a rack middleware that constructs its own routes using the DSL (much like a sinatra application would).

Perhaps you should create a pretend API outside of your rails application to better understand how middleware works.

@seivan
Copy link
Author

seivan commented Dec 13, 2010

Yeah I figured that out. But how would interacting with Rails models, gems and helpers work.
Could it share the Gemfile with a rails application? Could I plug in Devise into it?

@benschwarz
Copy link

If you keep it within your rails application, and load it alongside the rails environment (also add it to your config.ru) you'll have access to the core classes (your models).

Devise would just sit over the top—although I'd look into the authenticated examples that are in the sinatra demo app that intridea created for you :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants