A
A
Anton Ivanov2015-05-07 08:39:34
Ruby on Rails
Anton Ivanov, 2015-05-07 08:39:34

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

2 answer(s)
V
vsuhachev, 2015-05-07
@vsuhachev

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

And now in app/views/skins/my_skin you can create templates for any controller, including layout/application.html.erb

V
Vladimir Miroshnichenko, 2015-05-07
@gururuby

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 question

Ask a Question

731 491 924 answers to any question