All threads / Manage Assets With Rails Assets Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Manage Assets With Rails Assets Discussion

Love rails assets. I first found out about it about a year ago, and it quickly became one of my favorite ways to grab front end libs. :)

Jamie Barton ·

I found it only a few weeks ago. I love how easy it is to use. Absolutely brilliant.

It's really, really well done. Props to the authors!

Reply
Reply

I have many app using asset as regular mode and this the first time hear about rails asset. Thanks for that. I'm going definitely change to this

I'm definitely migrating over some older apps too! :)

Reply

Great Stuff Chris... This is definitely a better way to add frontend libs. One more tool for the toolchain....

Reply

So awesome! I was using bower-rails and was not aware of this option. Thanks so much for sharing Chris!

Reply

That's awesome, Thank you Chris I never thought a such thing exists... But does this work for all libraries ? after watching the video I tried rails-assets-ckeditor but it seems that I am getting errors like ActionController::RoutingError (No route matches [GET] "/lang/en.js"): ........

It should, but with more complex things like ckeditor, you might have to have those lang/en.js files compiled separately. Something like this based upon the filename in the Rails Assets gem.

config.assets.precompile += %w( lang/en.js )

This is definitely one part where the documentation with Rails Assets is poor.

Reply

Hi I am trying Rails Assets but I approach to a problem. I included Bourbon but when I tried use any mixin Rails told me that mixin is undefined. What to do?

If you haven't tried this already, you'll probably want to include bourbon with @import instead of the require statements so you can use it in your sass code.

Reply
Mohnish Jadwani ·

Thanks for sharing a screencast on this Chris. Recently we used the same thing in one of our client projects. As a first timer to it back then, I found it a little difficult to figure out where could I find runtime dependencies to the gems I'd like to use from the Rails Assets site. I've written a blog( http://www.cybrilla.com/blo... ) on how one could find runtime dependencies for the gems they'd like to use via Rails assets.

Awesome post! Thanks for sharing that Mohnish.

Mohnish Jadwani ·

Thanks for the encouragement Chris. Really glad you found it useful :)

Reply

Great video. I experimented by switching out my bootstrap-sass gem. The one thing I'm not understanding, is how do you tell rails-assets the version constraints you would like to stay within like the convention with rubygems? Thx!

I believe it works by just setting the version on the gem you include.

gem "rails-assets-bootstrap", "1.0.0"

Thanks for the quick response Chris. I'm assuming that if an explicit version is not specified, rails-assets will take the latest available version then... correct? Love the videos!

You are correct. It'll use that latest version of the library. And thanks! :D

Reply
chasefoto ·

Hey Chris - how are custom styles handled? Do we simply place them into the application.css file? Or are we required to build a separate customization file?

If you're trying to customize something like bootstrap, you can do this: Instead of doing the *= require bootstrap, you can do @import "bootstrap" to import the file using SASS and put your custom variables above the import to override the defaults.

Basically it doesn't change from how you would normally do it, but it can be a little unclear since they don't give you any instructions. Does that make sense though?

chasefoto ·

Yep, that makes total sense. Thanks for clarifying that for me Chris!

Reply

I often had kind of feeling that using bower and rubygems for such simple task as fetching vendor assets is too much overhead. So I wrote https://github.com/torba-rb.... Please, check it out.

Reply
Reply
Reply

Awesome Awesomer Awesomesttttt! I was using bower-rails and was not aware of this option. Thanks so much for sharing Chris!

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.