【问题标题】:Can't open Hartl's sample_app on local server无法在本地服务器上打开 Hartl 的 sample_app
【发布时间】:2015-02-09 01:49:36
【问题描述】:

我正在学习 Hartl 的教程,直到第 11 章一切正常。我按照要求做了第 11 章中的所有事情(几次,也许这是问题?)突然我无法在本地服务器上打开应用程序。 当我应该播种数据库时问题就开始了,所以我重置它并(不成功)播种了几次。最后,我设法播种 db,但问题仍然存在。

这是我在本地服务器上得到的,但我不知道这个参数是什么:

wrong number of arguments (2 for 1) for `asset-path' (in /home/aki/sample_app/app/assets/stylesheets/bootstrap_and_overrides.css.scss:1)

Extracted source (around line #1):

$iconSpritePath: asset-path('glyphicons-halflings.png', image);
$iconWhiteSpritePath: asset-url("glyphicons-halflings-white.png", image);

@import "bootstrap";

Rails.root: /home/aki/sample_app

Application Trace | Framework Trace | Full Trace
app/assets/stylesheets/bootstrap_and_overrides.css.scss:1
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2752615510238668489_70204869722340'

如果您需要其他文件中的“洞察”,我会发布它们,我不知道问题出在哪里..请帮助:)

【问题讨论】:

  • 感谢您的更新,我的回答应该可以帮助您解决问题
  • 谢谢,我现在解决了问题..

标签: ruby-on-rails railstutorial.org


【解决方案1】:

理解错误

首先,学习正确阅读和理解错误消息很重要:

wrong number of arguments (2 for 1) for `asset-path` (in 
/app/assets/stylesheets/bootstrap_and_overrides.css.scss:1)

这基本上是说,asset-path 助手有 2 个参数,但预计只有 1 个。它不知道如何处理第二个参数。

它还会显示此错误所在的位置,为您提供错误文件的确切路径:bootstrap_and_overrides.css.scss

错误本身

因此,当您了解了这一点后,您可以打开文件并更改您的代码:

$iconSpritePath: asset-path('glyphicons-halflings.png', image);
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);

到:

$iconSpritePath: asset-path('glyphicons-halflings.png');
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png');

我只是删除了第二个参数imageasset-path & asset-url 助手只接受一个 single 参数,如错误和described in their docs 中所述。

【讨论】:

  • 谢谢,它成功了,你是真正的冠军! :) 我不知道为什么会有那个“图像”论点……
猜你喜欢
  • 2016-07-10
  • 2017-01-27
  • 1970-01-01
  • 1970-01-01
  • 2016-12-10
  • 2013-02-16
  • 1970-01-01
  • 2012-07-24
  • 1970-01-01
相关资源
最近更新 更多