-1
我有一个基本的Ruby on Rails服务器设置。如何让index.html.rb运行
在routes.rb中我有这样的:
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
root :to => "home#index"
end
在我的控制器/ application_controller.rb我有这样的:
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
end
最后我有/app/views/posts/index.html .erb中包含一些基本的HTML。如何让我的页面指向该HTML文件。
您可以生成帖子控制器并添加索引操作:'rails generate controller posts index'。在默认情况下,对帖子控制器的索引操作将使用'app/views/posts/index.html.erb'模板。 – taro
不知道你的意思是'localhost:3000/posts'还是'<%= link_to“Posts”,posts_path'%> – MurifoX
假设我删除posts文件夹,该如何让网站转到HTML.rb页面? – sebi