的Gemfile:
# Component requirements
gem 'bcrypt-ruby', :require => "bcrypt"
gem 'sass'
gem 'haml'
gem 'coffee-script'
gem 'activerecord', :require => "active_record"
gem 'sqlite3'
# Test requirements
# Padrino Stable Gem
gem 'padrino', '0.10.7'
application.haml:
= stylesheet_link_tag 'reset'
= stylesheet_link_tag 'application'
样式表位于public / stylesheets / application.scss
帕德里诺开始......
当我刷新页面终端时写:
DEBUG - GET (0.0009ms) /stylesheets/application.css?1340975740 - 404 Not Found
[2012-06-29 17:15:40] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
请帮助我。
答案 0 :(得分:3)
我的Padrino版本是0.11.2
我创建了一个带有“-c scss”选项的项目,如
padrino-gen project mainsystem -a mysql -d datamapper -t rspec -s jquery -e haml -c scss -m mocha
我的Gemfile中有一行“gem'sssss”,还有一个 lib / scss_init.rb 文件
module ScssInitializer
def self.registered(app)
# Enables support for SCSS template reloading in rack applications.
# See http://nex-3.com/posts/88-sass-supports-rack for more details.
# Store SCSS files (by default) within 'app/stylesheets'
require 'sass/plugin/rack'
Sass::Plugin.options[:syntax] = :scss
Sass::Plugin.options[:template_location] = Padrino.root("app/stylesheets")
Sass::Plugin.options[:css_location] = Padrino.root("public/stylesheets")
app.use Sass::Plugin::Rack
end
end
我将 app / stylesheets / foo.scss 和访问权限添加到localhost:3000 / stylesheets / foo.css, public / stylesheets / default.css 生成。< / p>
答案 1 :(得分:0)
对于Padrino v.1.13.1有点不同
我创建了文件 config / initializers / sass.rb ,就像smokycat的答案一样。
module ScssInitializer
def self.registered(app)
require 'sass/plugin/rack'
Sass::Plugin.options[:syntax] = :scss
Sass::Plugin.options[:template_location] = Padrino.root("app/stylesheets")
Sass::Plugin.options[:css_location] = Padrino.root("public/stylesheets")
app.use Sass::Plugin::Rack
end
end
但我仍有一些问题,如:
ERROR - NameError - uninitialized constant YourAppName::App::SassInitializer:
/Users/user/your_app/join/app/app.rb:3:in `<class:App>'
ERROR - NameError - uninitialized constant YourAppName::App::SassInitializer:
/Users/user/your_app/join/app/app.rb:3:in `<class:App>'
我发现你必须添加到 config / boot.rb :
Padrino.dependency_paths.unshift Padrino.root('config/initializers/*.rb')
之后sass与padrino一起工作