Search code examples
ruby-on-railsruby-on-rails-4themes

How to add SB-admin v2 in Ruby-on-Rails app


I want to use SB Admin v2 Themes in my RoR application. I downloaded it and I don't know what's next to do.

BTW, I have gem bootstrap-sass in my Gemfile.


Solution

  • What I did is:

    1. Create an admin.html.erb layout with the base markup provided in index.html of the SB Admin 2 template

    2. Take a look at the js and css files included in the template and put them in their corresponding dirs in vendor/assets

    3. Add the corresponding requiere and import in application.js and application.scss manifests

    4. Don't include the assets for Morris charts until you really need them.

    5. In the file sb-admin-2.js remove the lines that add acttive css class for the menu.

    6. Implement menu using simple-navigation gem. It would look something like

      # encoding: utf-8
      
      SimpleNavigation::Configuration.run do |navigation|
        navigation.items do |primary|
          primary.item :dashboard, 'Inicio', admin_path, link_html: {icon_class: 'dashboard'}
          primary.item :clients, t_title('routes.clients'), admin_clients_path, link_html: { link_active: current_page?(admin_clients_path), icon_class: 'users' } do | clients |
            clients.item :clients_new, t_title('routes.new'), new_admin_client_path
          end
        end
      end
      
      SimpleNavigation.register_renderer admin_sidebar: Sb2AdminSidebarRenderer
      SimpleNavigation.config.selected_class = 'active'
      
    7. Not last but somewhere between the steps above you'd create partials for side menu, navbar top, etc.