我正在嘗試爲保留與後端和前端相關的資產創建單獨的文件夾。我計劃了以下文件夾結構:app/assets/dashboard/javascripts
而不是通常的app/assets/javascripts
。在導軌上包含ruby中的自定義文件夾特定資產
後端經由app/views/layouts/dashboard.html.erb
早餐,包括以下列方式資產:
<%= stylesheet_link_tag 'dashboard/dashboard', params[:controller], media: 'all' %>
<%= javascript_include_tag 'dashboard/dashboard', params[:controller] %>
前端經由app/views/layouts/application.html.erb
早餐,包括以下列方式資產:
<%= stylesheet_link_tag 'store/application', params[:controller], media: 'all' %>
<%= javascript_include_tag 'store/application', params[:controller] %>
我不確定以這種方式包含資產的正確方法是什麼,因此獲得404 not found
錯誤控制檯中的http://dashboard.localhost.com:3000/javascripts/dashboard/javascripts/dashboard.js
我也嘗試將腳本路徑更改爲<%= javascript_include_tag 'store/javascripts/application', params[:controller] %>
,但它也不起作用。 還試圖加入以下的代碼塊中提到here到application.rb中,但它並沒有工作,要麼:是
Dir.glob("#{Rails.root}/app/assets/**/").each do |path|
config.assets.paths << path
end
通過這些設置在控制檯填充路徑如下:
[9] pry(main)> Rails.application.config.assets.paths
=> ["/home/vipin8169/projectRoot/inmonarch_website/app/assets/images",
"/home/vipin8169/projectRoot/xyz/app/assets/javascripts",
"/home/vipin8169/projectRoot/xyz/app/assets/stylesheets",
"/home/vipin8169/projectRoot/xyz/vendor/assets/javascripts",
"/home/vipin8169/projectRoot/xyz/vendor/assets/stylesheets",
"/home/vipin8169/.rvm/gems/[email protected]/gems/jquery-rails-4.1.0/vendor/assets/javascripts",
"/home/vipin8169/.rvm/gems/[email protected]/gems/coffee-rails-4.1.1/lib/assets/javascripts",
"/home/vipin8169/.rvm/gems/[email protected]/gems/react-rails-1.6.2/lib/assets/react-source/development-with-addons",
"/home/vipin8169/.rvm/gems/[email protected]/gems/react-rails-1.6.2/lib/assets/javascripts/",
"/home/vipin8169/.rvm/gems/[email protected]/gems/bootstrap-sass-3.3.6/assets/stylesheets",
"/home/vipin8169/.rvm/gems/[email protected]/gems/bootstrap-sass-3.3.6/assets/javascripts",
"/home/vipin8169/.rvm/gems/[email protected]/gems/bootstrap-sass-3.3.6/assets/fonts",
"/home/vipin8169/.rvm/gems/[email protected]/gems/bootstrap-sass-3.3.6/assets/images"]
是否支持rails,以這種方式更改資產目錄結構?
添加了這兩個:'config.assets.paths << Rails.root.join(「app」,「assets」,「dashboard」)''和'config.assets.paths << Rails.root.join(「應用程序「,」資產「,」商店「)',但仍然得到404的http://dashboard.localhost.com:3000/stylesheets/dashboard/dashboard.css – vipin8169
你重新啓動服務器? –
是的,我重新啓動 – vipin8169