Assets pipeline doesn't work in 'application.scss' in my Rails 4.2 app

后端 未结 3 1523
甜味超标
甜味超标 2021-01-26 03:42

I\'m new in Rails and apologize if that is a stupid question. But i cannot resolve my problem: I added Bootstrap to my new app but it still doesn\'t use any new styles.

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 04:06

    After several hours i've found a problem - my pages_controller was incorrect:

    class PagesController < ActionController::Base
      # Prevent CSRF attacks by raising an exception.
      # For APIs, you may want to use :null_session instead.
      protect_from_forgery with: :exception
    end
    

    instead of:

    class PagesController < ApplicationController
      def index_page
      end
    end
    

    Controllers should inherit from main Controller!

    P.S: Adding string layout "application" to the wrong controller also helped:

    class PagesController < ActionController::Base
      # Prevent CSRF attacks by raising an exception.
      # For APIs, you may want to use :null_session instead.
      protect_from_forgery with: :exception
      layout "application"
    end
    

    But I do not recommend go that way

提交回复
热议问题