简体   繁体   English

Ubuntu服务器14.04上的Rails,没有加载应用程序布局

[英]Rails on Ubuntu server 14.04, not loading application layout

I just finished my app in my development laptop, and now I am trying to deploy to an ubuntu server. 我刚刚在我的开发笔记本电脑上完成了我的应用程序,现在我正在尝试部署到ubuntu服务器。 I installed everything and ran rails s to try the development environment there. 我安装了所有东西并运行rails s来尝试那里的开发环境。 It works, but it never loads the css or js, I precompiled them and double checked that they are in the public assets folder. 它工作,但它永远不会加载css或js,我预编译它们并仔细检查它们是否在公共资产文件夹中。 The problem is that it never asks for them. 问题是它永远不会要求它们。 For example, my application layout view it like the usual (just as an idea, not the actual code, but it is not needed to explain): 例如,我的应用程序布局视图通常(只是作为一个想法,而不是实际的代码,但它不需要解释):

<html>
<head>
  ----rails calls to application.js and css 
</head>
<body>
  <%= yield %>
</body>
</html>

But when I load the login page, there is no css. 但是当我加载登录页面时,没有css。 I check the page source, and it only shows the <%= yield %> part, no html, body, or head tags, and of course no references to css or js. 我查看页面源代码,它只显示<%= yield%>部分,没有html,body或head标签,当然也没有对css或js的引用。 I login, and navigate the app correctly, but never is there any css or js files used. 我登录,并正确导航应用程序,但从来没有使用过任何css或js文件。

Why is this happening? 为什么会这样? Nothing changed in the code, just a different machine. 代码中没有任何变化,只是一台不同的机器。 I've tried it in different machines, just copying the folder with all my code, and running bundle install then rails s, and it works great, in 3 different machines. 我在不同的机器上试过它,只是用我的所有代码复制文件夹,然后运行bundle install然后运行rails,它在3种不同的机器上运行良好。 Why doesn't it work on the ubuntu server? 为什么它不能在ubuntu服务器上运行?

I finally got it working. 我终于搞定了。 For whatever reason, rails lost the default value of what view to render in the application controller. 无论出于何种原因,rails都会丢失应用程序控制器中要呈现的视图的默认值。 I added the following line to the application controller and it worked: 我将以下行添加到应用程序控制器并且它有效:

layout "application.html.erb"

No idea why this is needed, since it is the default. 不知道为什么需要它,因为它是默认的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM