Specific to a CSS page with a Rails application

I would like to test two different interfaces for my Rails application. Ideally, I would like to have two separate css files, one of which is associated with each interface (for example, new_interface.css and old_interface.css). I currently have two different partial interfaces for the interfaces, one of which is called _new_interface.html.erb and one is called _old_interface.html.erb. If I want to call the correct css file when loading a certain kind, how should I do it? For example, if I load _new_interface.html.erb, I want it to load the new_interface.css file and ignore the old_interface.css file.

My application.css:

/*
*= require_tree
*/
+5
source share
2 answers

, , , : Rails 3.1 css

, // , .

, css . content_for, , . /views/layouts/application.html.erb javascript <% = yield: view_specific_css% > .

<% content_for :view_specific_css do %>
    <%= stylesheet_link_tag "whatever %>
<% end %>
+5

application.css

application.html.haml/

body{:class => @old_layout ? "old_layout" : "new_layout"}

, , ,

@old_layout = true

css body.old_layout body.new_layout, scss, sass css, ,

body.old_layout{
  #all your old layout css goes here, all but body statements of course
}

body.new_layout{
  #all your new layout css goes here, all but body statements of course
}

, css. , .

+3

All Articles