ruby-on-railsdigital-oceanjammit

Jammit gem error on production


I am getting following error while deploying on production. can anyone help with solution? Thanks.

ActionView::Template::Error (undefined method `include_stylesheets' for #<#<Class:0x00000003d8e0e8>:0x00000002d0f730>):
    2: %html
    3:   %head
    4:     %title= Settings.app_name
    5:     = include_stylesheets :canvas, :media => 'all'
    6:     = include_javascripts :canvas
    7:     = javascript_include_tag 'home/custom.js.coffee'
    8:     = csrf_meta_tags
  app/views/layouts/home.html.haml:5:in `_app_views_layouts_home_html_haml___3948606540755903120_32481960'
  app/controllers/website/home_controller.rb:11:in `home'

Solution

  • Some time back I ran in to the same problem

    Error ActionView::Template::Error (undefined method 'include_stylesheets' for #<#<Class:0x00000003d14ae9>:0x00000002e02770>):

    This means that jammit gem is not loaded properly. To do this check following your web application

    1 . gem is included in your gem file

        gem "jammit"
    

    2 . gem is loaded in your environment.rb file (in your case it would be production.rb I think) Find following code in environment file

    config.before_initialize do
    end
    

    and write config.gem "jammit" in between block's do -- end

    3 . ANd as @Dimitri Jorge said you need to run jammit b/w updating the source and symlinking to the new release. So if you are using capistrano require jammit in deploy.rb

    require 'jammit'
    

    and then

      task :generate_assets, :roles => :web do
        run "cd #{your_path_to_deploy_directory}/current && bundle exec jammit"
      end
      after "deploy", "deploy:generate_assets"
    

    I hope this solves the issue. Gotcha ;)