Answer the question
In order to leave comments, you need to log in
How is it more logical to make a website templating on rails?
Hello.
There is a project on rails, the site of which can (should) have a very different design. Data is always the same
Nothing better than choosing a layout based on the selected design, I did not come up with. But maybe there is some better way?
Answer the question
In order to leave comments, you need to log in
Rails has an array view_path, which contains the paths along which the template is searched in turn from the beginning to the end.
You can stick your path into this array.
In a controller (for example, in ApplicationController)
before_action :select_skin
protected \
def select_skin
# тут логика по выбору скина, например:
prepend_view_path "app/views/skins/#{session[:skin]}"
end
You can, in theory, use a data model that will describe your layout so as not to produce them, but here you also need to look at what will be suitable in terms of ease of adding template changes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question