html - Specify a style sheet in Ruby on Rails -


i have bootstrap gem install on app want include special style sheet login page. how include style sheet without making stylesheet global views (this happening me.)

1) in controller method renders login page, add following line @ end of method:

render :layout => false 

that code prevent application.html.erb layout being applied login page, assuming want 100% custom layout , stylesheet. if you're happy global layout being applied (the structure of page, including header or footer partials, etc.), ignore step.

2) in login.html.erb (or whatever file contains view), you'll need following line, point @ specific css file:

<%= stylesheet_link_tag 'foo', media: 'print, screen' %> 

where foo points foo.css file contained in app/assets/stylesheets directory. can skip media bit if don't want differentiate between stylesheet media versions, may run issue unstyled view if user ever tries print page, or if you're using responsive layout.

3) before stylesheet link tag work, you'll have tell rails precompile it. in your_app/config/initializers/assets.rb, add following line:

rails.application.config.assets.precompile += %w( foo.css ) 

4) restart rails application.

5) create , write foo.css file.

you should see view specific css being applied. also... herd u liek mudkipz.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -