0

in my website i want to dynamically assign Themes in application.erb.html using dropdown on selected change of my ruby on rails application..

my application.html.erb file as follows

<%= stylesheet_link_tag "#{current_theme}" %> 
<%= select_tag(:current_theme, options_for_select([['Cerulean'], ['superhero'], 'Amelia'], ['Cosmo']])) %>

i want change my current theme dynamically my requirement is want to assign theme on dropdown select change

please help me

Muralikrishna
  • 245
  • 1
  • 4
  • 15

1 Answers1

0

First of all you need to create separate directories for each theme so they can be managed in convenient way. Next you select a default theme and store it in the browser session. When user changes the theme you need to trigger change event on dropdown, update the session and select the theme. So in your layouts/application.html.haml you will do something like this.

<%= stylesheet_link_tag "#{session[:theme]}" %> 
<%= select_tag(:current_theme, options_for_select([['Cerulean'], ['superhero'], 'Amelia'], ['Cosmo']])) %>
benchwarmer
  • 2,764
  • 23
  • 25