ruby - Sinatra NoMethodError at / undefined method `stylesheet_link_tag' for # -


i making app sinatra , i've been working hours try implement bootstrap in it, , realizing how easier in rails.

anyways, when run web server , go /, see error relating line <%= stylesheet_link_tag 'app', media: 'all' %> put in app.erb view(the index of webapp). line meant load scss file in assets/stylesheets folder, , file contains @import values bootstrap.

i'm using sinatra-asset-pipeline gem, , i've set correctly according instructions on github page. i've been trying lots of things past 4 hours , nothing has worked. here's code important files:

assets/stylesheets/app.scss:

@import "bootstrap-sprockets"; @import "bootstrap"; 

views/app.erb:

<!doctype html> <html>    <head>     <title>salah kayali</title>     <%= stylesheet_link_tag 'app', media: 'all' %>     <%= javascript_include_tag 'app' %>     <meta name="viewport" content="width=device-width, initial-scale=1">   </head>    <body>     <%= partial :header %>   </body>  </html> 

app.rb:

require 'sinatra/partial' require 'rubygems' require 'sinatra' # set :bind, '0.0.0.0' require 'sinatra/asset_pipeline'  class app < sinatra::base     register sinatra::partial     configure     set :assets_precompile, %w(app.js app.scss *.png *.jpg *.svg *.eot *.ttf *.woff)     set :assets_css_compressor, :sass     set :assets_js_compressor, :uglifier         register sinatra::assetpipeline          if defined?(railsassets)       railsassets.load_paths.each |path|         settings.sprockets.append_path(path)       end     end   end    enable :partial_underscores     set :partial_template_engine, :erb    '/'     erb :app   end   run! if __file__ == $0 end 

config.ru:

require 'rubygems' require 'bundler' bundler.require run app 

rakefile:

require 'sinatra/asset_pipeline/task' require './app'  sinatra::assetpipeline::task.define! app 

gemfile:

source "https://rubygems.org" ruby "2.2.3"  gem 'bundler', '~> 1.10.6'  gem 'sinatra', require: 'sinatra/base' gem 'sinatra-asset-pipeline', require: 'sinatra/asset_pipeline'  gem 'thin', '~> 1.6.4'  gem 'sass', '~> 3.4.18'  gem 'coffee-script', '~> 2.4.1'  gem 'uglifier', '~> 2.7.2'  gem 'rack-coffee', '~> 1.0.3'  gem 'sinatra-partial'  source 'https://rails-assets.org'   gem 'rails-assets-jquery'   gem 'rails-assets-bootstrap-sass' end 

i hope can help, don't know do. i'm used rails, asset-pipeline exists , takes care of everything. i'm forcing myself make webapp sinatra, though, can understand happens when "automagically" create things rails.

here link screenshot of error output in browser: http://puu.sh/ktuia/1d8396b034.png

your problem stylesheet_link_tag , javascript_include_tag part of actionview, 1 of gems underlying rails (i.e. see actionview::helpers::assettaghelper).

according sinatra-asset-pipeline documentation:

now when in place can use helpers provided sprockets-helpers

looking @ sprocket-helpers example need this:

<link rel="stylesheet" href="<%= stylesheet_path 'application' %>"> <script src="<%= javascript_path 'application' %>"></script> 

so you're looking stylesheet_path , javascript_path rather stylesheet_link_tag , javascript_include_tag.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -