0

I have:

<&= stylesheet_link_tag    "application", :media => "all" %>

but I am adding a (completely) alternative layout for some of the views in my application, with separate stylesheets. I would like to link the existing layout to only some of the stylesheets, and add others. What do I need to change here?

Lucy Weatherford
  • 5,452
  • 16
  • 50
  • 76

4 Answers4

1

for this you can create new file in views/layout as similar to your application.html.erb for example i am creating home.html.erb.Link your all stylesheets and js files in that and finally just add that layout name in your required controller as layout 'home'

shrikant1712
  • 4,336
  • 1
  • 24
  • 42
  • That's what I did, but I want to know what should I write in the stylesheet_link_tag line in the new layout and in the old one, so that they will each link to their own stylesheets – Lucy Weatherford Apr 15 '13 at 11:40
  • you just add your required stylesheets in your new lay out <%= stylesheet_link_tag('stylesheet1','stylesheet2', :media => "all") %> – shrikant1712 Apr 15 '13 at 11:52
  • Thank you. But should I leave `media=> all` there? wouldn't that call all the stylesheets including the other layout ones? – Lucy Weatherford Apr 15 '13 at 12:02
0

You can use separate manifest file and include those manifest file This answer will help you how to do this

Community
  • 1
  • 1
Amar
  • 6,874
  • 4
  • 25
  • 23
  • I currently have a controller render a different layout file, and I'm trying to have a separate layout. Is that possible as well? – Lucy Weatherford Apr 15 '13 at 11:17
  • Yes,it is you can in your layout suppose it's sigin lay out you can use signin manifest – Amar Apr 15 '13 at 11:35
0

It specifies that your application.css should be loaded when the page is viewed in all media types. It's a CSS property, not a Rails property.

See http://www.w3.org/TR/CSS2/media.html#media-sheets for more details.

sevenseacat
  • 24,699
  • 6
  • 63
  • 88
0

You can add a separate layout for whole controller or for specific actions

For example:

in your controller:

layout :resolve_layout
 #controller code
 ...
def resolve_layout
    case action_name
    when "new", "create", "wait_conformation"
      "customer_layout"    
    else
      "producer_layout"
    end
end

Here customer_layout & producer_layout are layout files.

Raghuveer
  • 2,630
  • 3
  • 29
  • 59