如何在Ruby-on-Rails应用程序中添加SB-admin v2

时间:2015-05-22 02:46:40

标签: ruby-on-rails ruby-on-rails-4 themes

我是Ruby on Rails中的一个菜鸟。我想在我的RoR应用程序中使用SB Admin v2 Themes。我下载了它,但我不知道接下来要做什么。

顺便说一句,我的bootstrap-sass中有宝石Gemfile

3 个答案:

答案 0 :(得分:5)

我已经回答了这个问题,虽然已经有人回答,如果有人处于同样的情况下可能会觉得这很有帮助,前段时间我已经开发了一个宝石来添加sb-admin-2的所有资产主题,在这里你有:https://github.com/dreamingechoes/bootstrap_sb_admin_base_v2

将此行添加到应用程序的Gemfile:

gem 'bootstrap_sb_admin_base_v2'

然后执行:

$ bundle

或者自己安装:

$ gem install bootstrap_sb_admin_base_v2

然后,将其添加到application.js文件中:

//= require bootstrap_sb_admin_base_v2

并将此行放入application.css文件中:

*= require bootstrap_sb_admin_base_v2

您已准备好在Rails应用程序中使用基于Bootstrap的管理主题SB Admin 2的HTML结构。

问候! :)

答案 1 :(得分:2)

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.

答案 2 :(得分:0)

试试bower-rails - 它有sb-admin-2包。

参见例如http://makandracards.com/makandra/28851-managing-vendor-assets-in-rails-with-bower