how do gems add routes to an app

The simplest way is if the gem has a config/[gem name]/routes.rb file in its directory structure. If it does, then the routes defined in that file will be merged into whatever other routes you define in your own routes.rb file in your application. When such a route has been merged into your app, you can see it when you type `rake routes` at the command prompt. It will be set off from the other routes, usually by a namespace.

Note that Rails uses the "first match wins" strategy here, so if you want to override a route that will be claimed later by a gem (gem routes load after the application's own routes) then if your app defines the same route, whatever you have defined in your routes file will own that route, and the route defined in the gem will be ignored.

I believe there are other ways that a route can be defined programmatically, consult the Rails Guide on "Routing from the outside in" for details and links to the API documentation.

Walter

how do gems add their routes to an app

The simplest way is if the gem has a config/[gem name]/routes.rb file

sorry, this should be config/routes.rb, the gem name isn't in that path

Thanks How does spree_sitemap add it’s routes because it doesn’t have a config/routes.rb

>
>
>>
>> how do gems add their routes to an app
>>
>
> The simplest way is if the gem has a config/[gem name]/routes.rb file

sorry, this should be config/routes.rb, the gem name isn't in that path

> in its directory structure. If it does, then the routes defined in that file will be merged into whatever other routes you define in your own routes.rb file in your application. When such a route has been merged into your app, you can see it when you type `rake routes` at the command prompt. It will be set off from the other routes, usually by a namespace.
>
> Note that Rails uses the "first match wins" strategy here, so if you want to override a route that will be claimed later by a gem (gem routes load after the application's own routes) then if your app defines the same route, whatever you have defined in your routes file will own that route, and the route defined in the gem will be ignored.
>
> I believe there are other ways that a route can be defined programmatically, consult the Rails Guide on "Routing from the outside in" for details and links to the API documentation.
>
> Walter
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/50714B08-1D89-4E4F-940C-5AFD7F15DC90%40wdstudio.com.
> For more options, visit https://groups.google.com/d/optout.

Thanks How does spree_sitemap add it's routes because it doesn't have a config/routes.rb

What else have you tried, besides just looking for that file? Did you read Routing from the outside in? Did you follow the links to the API, and see what the other options are for defining a route? Try using Github's search to look for the string `routes`, which is the entry point for this part of Rails. See if it occurs anywhere within the gem source. Let us know what you find.

Walter

The gem doesn’t have a config/routes.rb I couldn’t get help with it and I didn’t know you had replied so I wrote my own and but it had an error and trying to get help someone asked me to put it on git as a public repository so you can see it at github.com/mices/spree_sitemap I don’t think you would wanna just put it in your gemfile and bundle better download and extract it because I didn’t fill out the readme and spec and stuff like that and in case there’s a difference please note it’s not necessarily a gem it’s a spree extension that you can quickly and easily learn about by googling “spree rest api customization” Thanks