ruby 2.1.3
Rails 4.2.3
ローカルでのPCはmac
sakuraはVPSのcentos
nginx1.8.0
unicorn
にてサイトを構築中です。
現在サイトをIPで公開出来る様になったのですがcssとjsが反映されずに困っております。
viewsのテキストのみ表示されている状態です。
エラー内容としてはapplication.cssが読み込まれていないのかと。(JS共に)
http://xxx.xxx.xxx.xxx/stylesheets/application.css Failed to load resource: the server responded with a status of 404 (Not Found) http://xxx.xxx.xxx.xxx/javascripts/application.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://xxx.xxx.xxx.xxx/stylesheets/application.css を読み込むと以下になります。
The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.
cssの設置場所は
/home/myapps/myapp1/app/assets/stylesheets/application.css
となります。
viewのcssタグの設置場所
/home/myapps/myapp1/app/views/layouts/application.html.erb
<%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %>
これかなーと思う事で。。。
/home/myapps/myapp1/config/environments/production.rb
config.assets.css_compressor = :sass config.assets.compile = true
を設定しております。
developmentの環境では読み込み問題御座いません。
権限などのも問題なのかなーとも考えましたがassets, stylesheets, application.css 全て755となります。
ここの設定が足りないなど御座いましたらご指摘頂けると有難いです。
宜しくお願いします。
9/28 16:38追加です。
少し進展しまして。
/home/myapps/myapp1/public/assets/
ここにcssを置いて、読まれるhtml.erbファイルに
<%= stylesheet_link_tag "/assets/application-xxxxxxxxxxxxxxxxxxxxxxxxxx.css", :media => "all" %>
を記載するとcssが適用されサイトがきちんと表示されました。
ただ全て手動で行っており、イケてないなーと。。。
この表記で対応したいと考えているのですが難しいでしょうか?
<%= stylesheet_link_tag "application", :media => "all" %>
Product環境に反映させる度に
/home/myapps/myapp1/app/assets/stylesheets/application.css
からpublicにコピーをしないといけないのでしょうか?
本番環境でも/home/myapps/myapp1/app/assets/stylesheets/application.cssに読みにいってくれるといいなーと考えているのですが。。。
Capistranoをインストールしておくとその辺りを行ってくれるような感じでしょうか?
宜しくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/28 07:36
退会済みユーザー
2015/09/30 03:25