Skip to content

Instantly share code, notes, and snippets.

Avatar

Trevor Harmon thetrevorharmon

View GitHub Profile
@anotheruiguy
anotheruiguy / web-fonts-asset-pipeline.md
Last active Jun 25, 2022
Custom Web Fonts and the Rails Asset Pipeline
View web-fonts-asset-pipeline.md

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@existentialmutt
existentialmutt / db_fixtures_export.rake
Last active Aug 12, 2021 — forked from kuboon/db_fixtures_export.rake
Generate fixtures from db. Readable by rake db:fixtures:load
View db_fixtures_export.rake
# lib/tasks/db_fixtures_export.rake
namespace 'db:fixtures' do
desc "generate fixtures from the current database"
task :export => :environment do
Rails.application.eager_load!
models = defined?(ApplicationRecord) ? ApplicationRecord.descendants : ActiveRecord::Base.descendants
models.each do |model|
puts "exporting: #{model}"