2013-07-22 77 views
0

編輯:我現在感覺很蠢。事實證明,這個問題是我global.scss:NoMethodError with Sprites(Compass + Rails)

.settings{ 
    @include site-icons-sprites(settings); 
} 

相反的站點圖標,精靈,我把站點圖標精靈,和它的工作如預期。


我試圖用羅盤精靈在Rails應用程序,但我不斷收到以下錯誤:

NoMethodError on line ["100"] of /usr/local/rvm/gems/ruby-1.9.3-p392/gems/compass-0.12.2/lib/compass/sass_extensions/functions/sprites.rb: undefined method `parent' for nil:NilClass 

我有兩個18x18px圖像名爲app文件夾>資產>圖像>站點圖標稱爲settings.png和search.png。我的代碼如下:

從模塊/ _sprites.scss:

@import "site-icons/*.png"; 
@include all-site-icons-sprites; 

從global.scss:

.settings{ 
    @include site-icons-sprites(settings); 
} 

從我的頭文件:

<li class="has-dropdown"> 
    <%= current_user.display_name %> 
    <span class="settings"> </span> 

    <ul class="dropdown"> 
     <li><%= link_to "Profile", current_user %></li> 
     <li><%= link_to "Dashboard", :root %></li> 
     <li><%= link_to "Logout", signout_path %></li> 
     <li> 
    </ul> 
</li> 

從我編譯的應用程序.css文件:

/* line 50, site-icons/*.png */ 
.site-icons-sprite, .site-icons-gear, .site-icons-search, .settings .site-icons-gear, .settings .site-icons-search { 
    background: url(/assets/site-icons-sd9044365e4.png) no-repeat; 
} 

/* line 60, ../../../../../../usr/local/rvm/gems/ruby-1.9.3-p392/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss */ 
.site-icons-gear { 
    background-position: 0 -20px; 
} 

/* line 60, ../../../../../../usr/local/rvm/gems/ruby-1.9.3-p392/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss */ 
.site-icons-search { 
    background-position: 0 0; 
} 

有沒有人遇到過這個?任何想法可能會導致它?

回答

0

我現在感覺很蠢。事實證明,這個問題是我global.scss:

.settings{ 
    @include site-icons-sprites(settings); 
} 

相反的站點圖標,精靈,我把站點圖標精靈,和它的工作如預期。

0

如果您的圖像名稱一旦以數字開頭