我认为我不太了解 rails 如何更新其视图页面。我在索引视图中删除了一段代码,当我去刷新页面时,代码仍然存在。我尝试重新启动服务器,但我想不出还能做什么。一定是一个我还没有学过的简单的东西,因为我是 Rails 新手。谢谢
编辑:
路线
projects GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project GET /projects/new(.:format) projects#new
edit_project GET /projects/:id/edit(.:format) projects#edit
project GET /projects/:id(.:format) projects#show
PUT /projects/:id(.:format) projects#update
DELETE /projects/:id(.:format) projects#destroy
search /search(.:format) projects#search
root / projects#index
配置/路由.rb:
FinalApp::Application.routes.draw do
resources :projects
match "search" => "projects#search", :as => :search
root :to => 'projects#index'
end
项目控制器中的索引操作:
def index
@projects = Project.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @projects }
end
end