I
I
Ivan Nesterovich2014-04-04 11:16:55
Ruby on Rails
Ivan Nesterovich, 2014-04-04 11:16:55

Ruby on Rails 4 - how to create your own path to assets?

Good day, gentlemen.
There is a need to create a path to assets in the following format
app/assets/backend/(images, stylesheets, javascripts)
app/assets/frontend/(images, stylesheets, javascripts) Added to
config/application.rb:

config.assets.paths << "#{Rails.root}/app/assets/backend/stylesheets"
    config.assets.paths << "#{Rails.root}/app/assets/backend/javascripts"
    config.assets.paths << "#{Rails.root}/app/assets/backend/images"

    config.assets.paths << "#{Rails.root}/app/assets/frontend/stylesheets"
    config.assets.paths << "#{Rails.root}/app/assets/frontend/javascripts"
    config.assets.paths << "#{Rails.root}/app/assets/frontend/images"

No files are created after assets:precompile and
= stylesheet_link_tag "frontend", media: "all"
which creates a link like this
/assets/frontend-54bc941008518ff11483bd79e3d5260e.css - file not found.
What's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Piranis, 2014-04-04
@Piranis

rake RAISL_ENV=production assets:precompile ?
and restart passenger or whatever your rails stack serves in production,
for example:
touch ./tmp/restart.txt
Also delete all compiled files before

D
Dmitry Andreev, 2015-02-11
@dag

you need to add everything to config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( some-js-file.js )
Rails.application.config.assets.precompile += %w( some -js-file.js ) -then-css-file.css )
and add paths above
# Add additional assets to the asset load path
Rails.application.config.assets.paths << "#{Rails.root}/app/assets/backend/stylesheets" Rails.application.config.assets.paths << "#{Rails.root}/app/assets/backend/javascripts" Rails.application.config.assets.paths <<"#{Rails.root}/app/assets/ backend/images"
Rails.application.config.assets.paths << "#{Rails.root}/app/assets/frontend/stylesheets"
Rails.application.config.assets.paths << "#{Rails.root}/app/assets/frontend/javascripts"
Rails.application.config.assets.paths << "#{Rails.root}/app/assets/frontend/images"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question