Showing posts with label sass. Show all posts
Showing posts with label sass. Show all posts

Wednesday, December 28, 2011

active-admin sass and rails 3

by sandipransing 0 comments
active_admin is the good way to provide rails administrative interface.
It provides front-end db administration and its customizable too :)
# Gemfile gem 'activeadmin' gem 'sass-rails' gem "meta_search", '>= 1.1.0.pre'
Bundle install, generate config & migrate db
bundle install rails g active_admin:install rake db:migrate Config
# config/initializers/active_admin.rb ActiveAdmin.setup do |config| config.site_title = "Web Site :: Admin Panel" config.site_title_link = "/" config.default_namespace = :siteadmin config.authentication_method = :authenticate_admin_user! config.current_user_method = :current_admin_user config.logout_link_method = :delete end
Registering new resource
rails generate active_admin:resource category Customization
# app/admin/categories.rb ActiveAdmin.register Category do scope :published form do |f| f.inputs do f.input :name, :label => 'Name' f.input :for_type, :label => "Category Type" end f.buttons end end Adding Dashboard
ActiveAdmin::Dashboards.build do section "Recent Categories" do table_for Category.published.recent.limit(2) do column :name do |c| link_to c.name, [:admin, c] end column :created_at end strong { link_to "View All Categories", admin_categories_path } end end
Read More…

twitter bootstrap paginate and rails 3

by sandipransing 0 comments
Twitter bootstrap is css toolkit for rapid front-end UI development.
To get will-paginate working with bootstrap css we need to override default pagination link renderer.
Using Bootstrap-sass for rails 3
# Gemfile gem 'sass-rails' gem 'bootstrap-sass'
# app/assets/stylesheets/application.css.sass // Place all the styles related to the home controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ //= require bootstrap Add WillPaginate LinkRenderer to intitializer
# config/initializers/will_paginate.rb module WillPaginate module ActiveRecord module RelationMethods alias_method :per, :per_page alias_method :num_pages, :total_pages alias_method :total_count, :count end end module ActionView def will_paginate(collection = nil, options = {}) options[:inner_window] ||= 0 options[:outer_window] ||= 0 options[:class] ||= 'pagination pull-left' options[:renderer] ||= BootstrapLinkRenderer super.try :html_safe end class BootstrapLinkRenderer < LinkRenderer protected def html_container(html) tag :div, tag(:ul, html), container_attributes end def page_number(page) tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) end def previous_or_next_page(page, text, classname) tag :li, link(text, page || 'javascript:void(0)'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ') end def gap tag :li, link(super, 'javascript:void(0)'), :class => 'disabled' end end end end
Read More…

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter