0

I use rails 4 for a restFUL API and would like to use http://apidocjs.com/ as i did with php. I could generate my api documentation in /doc but after I'm wondering what is the best "rails way" to route to this doc. Should I create a controller or just routes to my html file like :

get '/doc', :to => redirect('/doc/index.html')

I tried it but I get

No route matches [GET] "/doc/index.html"

So what is the best way to do that ? I feel like I don't think "rails way"..

kleww
  • 101
  • 3
  • 8

3 Answers3

1

If your documentation is completely generated and just static html, you can simply place it within your public folder and it will be routed automatically. In other words, you can create the docs folder within the public folder and then access your pages via

http://example.com/docs/index.html

In development this would be

http://localhost:3000/docs/index.html

If you're looking for something more robust, I'd highly recommend high_voltage by thoughtbot.

Bart Jedrocha
  • 11,450
  • 5
  • 43
  • 53
0

You could try like this provided you have controller named as docs and action named as index.

 get 'docs', :to => 'docs#index', :as => 'doc'
sansarp
  • 1,446
  • 11
  • 18
  • Yeah i thought about this solution but create a controller just to show my doc is not too much ? =/ – kleww Feb 22 '15 at 17:00
0
resource :doc, only: :show

Then create this file

/app/views/docs/show.html

No controller needed

The URL will be

/doc
Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89