Using smaller files in Rails

I would like to ask how to use toiless files in a Rails application if they are placed under assets, but in a separate folder (let's call the "myless" folder) from the stylesheets. Another way to express this is to have the myless folder next to the "images", "javascript" and "stylesheets" folders in the assets folder.

How can I import them into application.css or into a .CSS file? What lines of code would I use? Do I need to add a method to environment.rb? What kind of gems should I use?

Any insight would be excellent. Please note that I am fairly new to Rails and am looking into various tutorials. Different implementations in different versions of Rails confuse me and I don't see a clear guide that I can find on the internet. I am currently trying to implement the bootstrap pattern, so I am asking this question. I got JavaScript and CSS down, but realized the template was using .less files. Help?

+3


source to share


1 answer


You can enable your application to support LESS by including the appropriate gem (s):

gem 'therubyracer'
gem 'less-rails'

      

Then run bundle install

. Assuming you have the appropriate stylesheets included in your stylesheet, you should be kind!



There is also rails-less-bootstrap if you want an easier way to include Bootstrap in your project.

Note: It is recommended to keep your stylesheets. Rather than keeping the directory myless

at the same level as images

, javascripts

and stylesheets

, you should consider moving it within your directory stylesheets

.

Hope it helps!

+6


source







All Articles