为什么rake资产预编译不起作用

时间:2013-04-19 10:35:05

标签: ruby-on-rails heroku asset-pipeline

我正在使用letrate gem
rake assets: precompile raises以下内容 我想在heroku上部署并引发同样的错误。

    /home/sunloverz/.rvm/rubies/ruby-1.9.3-p385/bin/ruby /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
    rake aborted!
    undefined method `rate_path' for #<Module:0x9d31338>
      (in /home/sunloverz/RubymineProjects/socialnews/app/assets/javascripts/letsrate.js.erb)
    /home/sunloverz/RubymineProjects/socialnews/app/assets/javascripts/letsrate.js.erb:13:in `block in singletonclass'
    /home/sunloverz/RubymineProjects/socialnews/app/assets/javascripts/letsrate.js.erb:65530:in `instance_eval'
    /home/sunloverz/RubymineProjects/socialnews/app/assets/javascripts/letsrate.js.erb:65530:in `singletonclass'
    /home/sunloverz/RubymineProjects/socialnews/app/assets/javascripts/letsrate.js.erb:65528:in `__tilt_74553360'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/tilt-1.3.7/lib/tilt/template.rb:144:in `call'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/tilt-1.3.7/lib/tilt/template.rb:144:in `evaluate'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/tilt-1.3.7/lib/tilt/template.rb:77:in `render'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:16:in `initialize'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
    Tasks: TOP => assets:precompile:primary
    (See full trace by running task with --trace)
    rake aborted!
    Command failed with status (1): [/home/sunloverz/.rvm/rubies/ruby-1.9.3-p38...]
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
    /home/sunloverz/.rvm/gems/ruby-1.9.3-p385/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
    Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

2 个答案:

答案 0 :(得分:0)

请检查错误

对于#“

”未定义的方法`rate_path'

您好budy请在部署到heroku之前对文件进行以下更改

------ ----- enviorment.rb

::ActiveSupport::Deprecation.silenced = true

------ ------- Production.rb

config.assets.compile = ['*.js', '*.css']
config.active_support.deprecation = :silence

------- ------- application.rb中

config.assets.enabled = true
config.assets.initialize_on_precompile = false

我在部署heroku时使用了这一步 确保使用“postgres”数据库和“瘦”服务器 希望你能解决这个问题。

答案 1 :(得分:0)

我遇到了同样的问题,我通过在 routes.rb

中添加此代码解决了这个问题
post '/rate', to: 'rater#create', as: 'rate'