E
E
Evgeny Skuridin2013-12-12 22:20:24
Ruby on Rails
Evgeny Skuridin, 2013-12-12 22:20:24

How can I implement themes with separate views and assets in rails?

Hello!
How can I implement themes with separate views and assets in rails?
Is it possible to make the generators also take into account the path to the topic?
We are talking about the simultaneous use of only one theme, but so that it is easy to switch them from the config.
Unfortunately, no definitive solution could be found.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Skuridin, 2013-12-13
@skuridin

It turned out something like this:

# config/application.rb

config.theme = 'default'
config.assets.paths << Rails.root.join('app/themes', config.theme, 'assets/javascripts')
config.assets.paths << Rails.root.join('app/themes', config.theme, 'assets/stylesheets')
config.assets.paths << Rails.root.join('app/themes', config.theme, 'assets/images')
config.assets.paths << Rails.root.join('app/themes', config.theme, 'assets/bower_components')

# app/controllers/application_controller.rb

prepend_view_path Rails.root.join('app/themes', Rails.application.config.theme, 'views')

If there is information on how to do the same, but more beautifully, I will wait.

A
Arkady Butermanov, 2013-12-12
@Arkadey

Stylesheets in a Rails application are usually included in a tag using the stylesheet_link_tag helper . Pass a file name to this helper based on the current theme selected by the user. For example:
, where the theme name is stored in ui_theme , and the corresponding stylesheet file is in the app/assets/stylesheets directory. Well, at least that's what I would do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question