简体   繁体   English

为什么无法通过rake资产进行预编译

[英]Why rake assets precompile doesn't work

I am using letsrate gem 我正在使用Letsrate宝石
rake assets: precompile raises the following. rake assets: precompile raises以下内容。
I wanted to deploy on heroku and raises the same error. 我想在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)

please check error that 请检查错误

"undefined method `rate_path' for # " “#的未定义方法`rate_path'”

hi budy please do following changes in file before deploy to heroku 嗨,好伙伴,请在部署到heroku之前先进行以下文件更改

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

::ActiveSupport::Deprecation.silenced = true

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

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

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

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

i used this step when deploying heroku make sure you using "postgres" database and "thin" server hope you are solve the issue. 我在部署heroku时使用了此步骤,请确保您使用“ postgres”数据库和“ thin”服务器,希望您能解决此问题。

我遇到了同样的问题,我通过在routes.rb中添加此代码来解决了这个问题

post '/rate', to: 'rater#create', as: 'rate'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM