0

我正在使用
rake assets: precompile raises以下 letrate gem。
我想在 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)
4

2 回答 2

0

请检查错误

“未定义的方法‘rate_path’用于#”

嗨伙计,请在部署到heroku之前对文件进行以下更改

------环境.rb-----

::ActiveSupport::Deprecation.silenced = true

------生产.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”数据库和“thin”服务器希望您能解决问题。

于 2013-04-19T10:51:48.023 回答
0

我有同样的问题,我通过在我的routes.rb中添加这段代码来解决它

post '/rate', to: 'rater#create', as: 'rate'
于 2015-09-27T22:17:45.907 回答