[英]Ruby on Rails: After change in view, website not updating
I don't think I quite understand how rails updates its view pages. 我不认为我非常理解rails如何更新其视图页面。 I have deleted a piece of code in my index view, and when I go to refresh page, the code is still present.
我在索引视图中删除了一段代码,当我转到刷新页面时,代码仍然存在。 I tried restarting the server, and I can't think what else to do.
我尝试重启服务器,我想不出还有什么可做的。 Must be a simple thing that I haven't learnt yet, as I'm new to rails.
必须是一件我尚未学到的简单事情,因为我是铁杆新手。 Thanks
谢谢
EDIT: 编辑:
Routes 路线
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
config/routes.rb: 配置/ routes.rb文件:
FinalApp::Application.routes.draw do
resources :projects
match "search" => "projects#search", :as => :search
root :to => 'projects#index'
end
Index action in Project Controller: 项目控制器中的索引操作:
def index
@projects = Project.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @projects }
end
end
If it stays the same after editing the html, you are not viewing what you think you are viewing. 如果在编辑html后它保持不变,则表示您没有查看您认为正在查看的内容。
尝试删除应用公用文件夹中的index.html文件。
确保config/routes.rb
指向正确的控制器和操作。
I was doing a tutorial and had run rails server
in the directory outside of app
. 我正在做一个教程,并在
app
之外的目录中运行rails server
。 I'm pretty sure I stopped and started the server a couple of times, navigated around directories, then I made some changes and they weren't showing. 我很确定我已停止并启动服务器几次,浏览目录,然后我做了一些更改而他们没有显示。 I stopped the server, changed into
app
then started the server again, I got what I expected. 我停止了服务器,更改为
app
然后再次启动服务器,我得到了我的预期。 If you're having trouble, it might be worth checking that. 如果您遇到麻烦,可能值得检查一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.