【问题标题】:Converted Rails 3.0.9 to Rails 3.1.1 and lost my stylesheets将 Rails 3.0.9 转换为 Rails 3.1.1 并丢失了我的样式表
【发布时间】:2012-01-14 11:01:44
【问题描述】:

大概我的 Javascript 文件也丢失了……

我将样式表从 public/ 移动到 app/assets/stylesheets (仅供参考,也没有在 public/assets 中找到它们)。

搜索错误让我更加困惑......

错误是 ActionController::RoutingError (没有路由匹配 [GET] "/assets/application.css")

我的纯 Rails 3.1 应用程序的路线没有提及资产,但它工作正常。

application.css 的内容

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
*/

除了按照这些指示(可能不太好)之外,我不确定我还应该在这里放什么:Upgrade Rails 3 to 3.1

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3


【解决方案1】:

在启用资产管道的 Rails 3.1 中,所有资产(javascript、css 和图像)都可以通过浏览器中的 assets 路径访问,而不再像以前那样通过 javascriptsstylesheets 访问。这是因为 Rails 会操纵您的资产(编译、捆绑和缩小)。

一定要关注Railscasts episode on the Asset Pipeline

【讨论】:

【解决方案2】:

这个 railscasts 可能对你也很有用。

http://railscasts.com/episodes/282-upgrading-to-rails-3-1

【讨论】:

    【解决方案3】:

    http://ruby.railstutorial.org/chapters/rails-3-1#to

    对于那些登陆这里寻求迁移到 3.1 帮助的人来说,这里是另一个很好的资源。 Michael Hartl 逐步将现有应用升级到 Rails 3.1

    这是我几周前遇到这个确切问题时找到答案的地方。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      • 1970-01-01
      • 2014-05-15
      • 2019-10-30
      • 2015-07-25
      • 1970-01-01
      • 2011-12-22
      相关资源
      最近更新 更多