2017-09-01 13 views
0

私はgem ratyrateを使用していますが、ローカルでは問題なく動作しますが、実際には404エラーの画像が生成されます。プロダクション(英雄)の星評価が表示されない

私が見つけたいくつかのソリューションは、これらのだったが、彼らはあなたのあなたのconfig/environments/production.rbに追加

/initializer/raty_helper.rb https://github.com/wazery/ratyrate/blob/master/lib/ratyrate/helpers.rb

raty.js.rb

$.fn.raty.defaults.half = false; 
$.fn.raty.defaults.halfShow = true; 
$.fn.raty.defaults.path = '<%= asset_path('images') %>'; 
$.fn.raty.defaults.cancel = false; 

$(function(){ 
    $(".star").each(function() { 
    var $readonly = ($(this).attr('data-readonly') == 'true'); 
    var $half  = ($(this).attr('data-enable-half') == 'true'); 
    var $halfShow = ($(this).attr('data-half-show') == 'true'); 
    var $single = ($(this).attr('data-single') == 'true'); 
    $(this).raty({ 
     score: function() { 
     return $(this).attr('data-rating') 
     }, 
     number: function() { 
     return $(this).attr('data-star-count') 
     }, 
     half:  $half, 
     halfShow: $halfShow, 
     single:  $single, 
     path:  $(this).attr('data-star-path'), 
     starOn:  '/star-on.png', 
     starOff:  '/star-off.png', 
     starHalf: '/star-half.png', 
     cancel:  $(this).attr('data-cancel'), 
     cancelPlace: $(this).attr('data-cancel-place'), 
     cancelHint: $(this).attr('data-cancel-hint'), 
     cancelOn: '/cancel-on.png', 
     cancelOff: '/cancel-off', 
     noRatedMsg: $(this).attr('data-no-rated-message'), 
     round:  $(this).attr('data-round'), 
     space:  $(this).attr('data-space'), 
     target:  $(this).attr('data-target'), 
     targetText: $(this).attr('data-target-text'), 
     targetType: $(this).attr('data-target-type'), 
     targetFormat: $(this).attr('data-target-format'), 
     targetScoret: $(this).attr('data-target-score'), 
     readOnly: $readonly, 
     click: function(score, evt) { 
     var _this = this; 
     if (score == null) { score = 0; } 
     $.post('<%= Rails.application.class.routes.url_helpers.rate_path %>', 
     { 
      score: score, 
      dimension: $(this).attr('data-dimension'), 
      id: $(this).attr('data-id'), 
      klass: $(this).attr('data-classname') 
     }, 
     function(data) { 
      if(data) { 
      // success code goes here ... 

      if ($(_this).attr('data-disable-after-rate') == 'true') { 
       $(_this).raty('set', { readOnly: true, score: score }); 
      } 
      } 
     }); 
     } 
    }); 
    }); 
}); 
+0

あなたは、いくつかのログを投稿できますか? – alexunger

+0

@bangbang GET domain.com /assets/star-off.png star-off.png –

答えて

2

を動作しません。

config.serve_static_assets = true

+0

それは動作しません:( –

+0

開発サーバーをプロダクションモードで起動させてもらえますか? – alexunger

+0

私はこれを解決しましたこれにより、 レールアセット:プリコンパイル –

1

ソリューションは、このコマンドを実行することです:

rails assets:precompile 
+0

がこれに結びついているため、アセットが変更されるたびに、または古いバージョンで終了するたびにこれを実行する必要があります。 – alexunger

関連する問題