开发者

Routing around static index.html in Rails

My rails application works okay, but I want there to be a static index.html page in front of it that has a link to the "start" of my application.

I don't know how to tell rails to go wherever it used to go before I put the index.html in.

So, I want "http://localhost:3000/start" to be what "http://localhost:3000" used to be before I put in the index.html.

I tried this in routes.rb: match 'start' => 'application'

I was thinking that would make /start get handled by application, but "applicatio开发者_开发技巧n" was all "Whatchoo talkin bout"


@Sam is correct: if there is a public/index.html, it trumps whatever's in your routes.rb file. Delete it with impunity and you will be happier.

Once you've done that, assuming your static page is in 'views/static/start.html', put this as the last line in config/routes.rb:

  root :to => 'static#start'


In your public folder if you have a filed called index.html the application will always go to that first.


Sure, put this in your routes.rb:

match 'start', controller: 'start', action: 'index'

(assuming you have a start_controller with an action 'index')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜