ActiveScaffold入れてみた

ユーザーテーブルがあって、モデルもあってという前提で

インスコ

./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold/

管理エリア作る

ユーザー管理でも作ってみる
routes.rbにルート情報書く/adminで使いたい

  #管理エリア 
  #active scaffold
  map.namespace(:admin) do |admin|
    admin.resources :users
  end

コントローラー作る

script/genetrate controller Admin::users

コントローラに書き足す

ログイン管理をやるやつをBaseクラスで作っておいてそいつを継承して

class Admin::UsersController < Admin::BaseController
	active_scaffold
	layout "admin"
	
	active_scaffold :user do |config|
		config.label = "ユーザー"
		config.columns = [:id, :login, :email, :created_at, :updated_at, :roles]
		list.columns.exclude :created_at
		list.sorting = {:id => 'ASC'}
		columns[:login].label = "ログインID"
		columns[:email].label = "メルアド"
		columns[:roles].label = "権限"
		columns[:created_at].label = "作成日"
		columns[:updated_at].label = "更新日"
	end

end

レイアウト作る

admin用レイアウト作る

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
 <title>Cards: <%= controller.action_name %></title>
 <%= javascript_include_tag :defaults %>
 <%= active_scaffold_includes %>
</head>
<body>
<p style="color: green"><%= flash[:notice] %></p>
<%= yield  %>
</body>
</html>

とりあえずこれで

コントローラーのとこの内容で中身はカスタマイズされてる。
詳細調べたら書く。