How to do static content in Rails?

后端 未结 8 948
孤城傲影
孤城傲影 2020-11-30 17:47

Looking at different options:

One is to just put the static pages in the public/ folder, but I do want the header from layout/application to be consistent.

I

8条回答
  •  醉酒成梦
    2020-11-30 18:29

    depends on the url structure, if you want the paths to come off of / (e.g. /about_us), then:

    map.connect ':action', :controller => "static"
    

    This should go at the very end of your routes file, Throw your .html.erb files into app/views/static and you are done.

    e.g: throwing in about_us.html.erb, will give you a page at /about_us.

    The item that you have in your question is great for a catch all route where you can analyze the array given to you at params[:path]. A bit more information on that at http://railscasts.com/episodes/46-catch-all-route

提交回复
热议问题