你如何从index.html.erb而不是index.html开始使用Rails项目?

par*_*lia 3 ruby-on-rails erb start-page

index.html为我的项目页面需要一些Ruby代码,所以我需要将其更改为.erb扩展名.如何配置Rails以将index.html.erb文件标识为项目的起始页而不是index.html文件?

Bar*_*her 6

您需要map.rootconfig/routes.rb文件中配置路径.

map.root :controller => "blogs"

# This would recognize http://www.example.com/ as
params = { :controller => 'blogs', :action => 'index' }

# and provide these named routes
root_url   # => 'http://www.example.com/'
root_path  # => ''
Run Code Online (Sandbox Code Playgroud)

http://api.rubyonrails.org/classes/ActionController/Routing.html