mkhairi / materialize-sass

Materializecss rubygem for Rails Asset Pipeline / Sprockets
http://materialize.labs.my/
MIT License
805 stars 243 forks source link

ActionController::RoutingError (No route matches [GET] "/fonts/roboto/Roboto-Light.ttf"): #101

Closed tdoganay closed 8 years ago

tdoganay commented 8 years ago

I get this error when my server is trying to get any of the roboto fonts. I've tried changing the src urls in _roboto.scss, putting all the fonts straight in the assets folder, and adding

config.assets.enabled = true  
config.assets.paths << "#{Rails.root}/app/assets/fonts/roboto" 

to my application.rb file. Nothing gets it to work.

My index.html.slim file:

doctype html
html

head
  meta[name="viewport" content="width=device-width, initial-scale=1"]
  link[type="text/css" rel="stylesheet" href="assets/materialize.css" media="screen,projection"]
  link[type="text/css" rel="stylesheet" href="assets/main.css.scss"]

body

.intro.deep-orange.lighten-2.z-depth-1
  h1.grey-text.text-lighten-5
    | Homepage
  h5.grey.lighten-4.grey-text.text-darken-1
    | Learn something new

- if user_signed_in?
  h1
    | Welcome, 
    = current_user.first_name
    | !
- else
  h1
    | Welcome!
- if !user_signed_in?
  p
    font[size="3"]
      | New? Sign up!: 
    = link_to 'New User', new_user_registration_path
  br
p
  font[size="3"]
    | Go to venues: 
  = link_to 'Venues',  'resources'
br
br
ul
  .row
  .col.s12.cards-container
    -Event.all.each do |event|
        =render 'card', event: event 

script[type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"]
script[type="text/javascript" src="assets/materialize.min.js"]

My Gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'yaml_db'

gem 'materialize-sass'

gem 'coffee-script-source', '1.8.0'

gem 'bookable', '~> 0.0.52'

gem 'responders', '~> 2.0'

gem 'devise'

gem 'omniauth-facebook'

gem "omniauth-google-oauth2"

gem 'mail_form', '~> 1.5', '>= 1.5.1'

gem 'sendgrid', '~> 1.2', '>= 1.2.4'

gem 'aws-sdk', '<2.0'

gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'

gem "cocaine", '~> 0.5.8'

gem 'slim-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

My assets folder:

assets/
  |--fonts/
  |  |--roboto/
  |   |   |--roboto fonts
  |
  |--images/
  |  |--images
  |
  |--javascripts/
  |  |--materialize.min.js
  |  |--application.js
  |
  |--stylesheets/
  |   |--components/
  |   |  |--materialize components
  |   |--application.css.scss
  |   |--main.css.scss
  |   |--materialize.scss

Thanks for the help.

rubendinho commented 8 years ago

Are you getting errors with any other components? This particular error is most likely due to the way you're adding the font path. You can see what the paths are actually being captured by the asset pipeline by running this in Rails Console Rails.application.config.assets.paths

Also did importing it directly in the application.scss file not work?

@import "materialize/components/roboto"; - to add only the fonts (not 100% sure if this alone will work) @import "materialize"; -to add everything

mkhairi commented 8 years ago

@tdoganay, seem like you did not load materialize component directly from this gem. if you intent to load font component manually you should change the src: url to src: font-url see _roboto.scss