# Puffer - YARAI (Yet Another Rails Admin Interface). Rails 3 only. Puffer was created to help project owner or moderators view and edit all the project`s data models. It is rails 3 only ## Keyfeatures * Full rails integration. Puffer has no configs, just DSL to create interfaces. And this DLS depends on rails convensions. * Flexibility. Puffer designed to be as flexible as possible, so you can create your own modules easily. * I18n. Surely. * Bla bla ## Installation. You can instal puffer as a gem:
gem install pufferOr in Gemfile:
gem "puffer"Next step is:
rails g puffer:installThis will install main puffer config file in your initializers and some css/js. ## Introduction. So, you have some data structure of your project. Let it`ll be like this:
create_table "users", :force => true do |t| t.string "email" t.string "password" t.datetime "created_at" t.datetime "updated_at" end create_table "posts", :force => true do |t| t.integer "user_id" t.string "title" t.text "body" t.datetime "created_at" t.datetime "updated_at" endAlso, you have two models:
class User < ActiveRecord::Base has_many :posts validates_presence_of :email, :password validates_length_of :password, :minimum => 6 end
class Profile < ActiveRecord::Base belongs_to :user validates_presence_of :name, :surname endAt first, lets generate puffers controllers:
rails g puffer:controller Userand
rails g puffer:controller PostThis will generate a kind of:
class Admin::PostsController < Puffer::Base before_filter :i_didnt_forget_to_protect_this index do field :id field :user_id field :title field :body field :created_at field :updated_at end form do field :id field :user_id field :title field :body field :created_at field :updated_at end endPuffer controller`s DSL creates all the actions we need. Next step - routing
namespace :admin resources :users do resources :posts end resources :posts endLet me explain this feature. Puffer tracks all the nested resources. So, with this routing structure we can access, for example, only specified user`s posts:
/admin/users/1/postRouting nesting defines admin interface resources nesting. ## Advanced usage Puffer can be used in other namespaces, then admin:
rails g puffer:controller moderator/postsAnd we`ll get posts controller for moderator:
class Moderator::PostsController < Puffer::Base before_filter :require_moderator config do destroy false group :posting end index do field :user_id field :title field :body end form do field :user_id field :title field :body field :created_at field :updated_at end endAs you can see, moderators can not destroy posts, also moderator`s posts controller placed at Posting tab of admin interface. And don`t forget about routing:
namespace :moderator do resources :posts end