admin_views 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/README.md +1 -1
  2. data/generators/admin_views/admin_views_generator.rb +17 -14
  3. data/generators/admin_views/templates/controllers/admin_controller.rb +21 -0
  4. data/generators/admin_views/templates/controllers/dashboard_controller.rb +27 -0
  5. data/generators/admin_views/templates/controllers/model_controller.rb +65 -0
  6. data/generators/admin_views/templates/helpers/admin_view_helper.rb +22 -0
  7. data/generators/admin_views/templates/stylesheets/admin.css +0 -0
  8. data/generators/admin_views/templates/stylesheets/formtastic-changes.css +0 -0
  9. data/generators/admin_views/templates/stylesheets/table.css +0 -0
  10. data/generators/admin_views/templates/views/dashboard/index.html.erb +17 -0
  11. data/generators/admin_views/templates/views/layouts/_header.html.erb +4 -0
  12. data/generators/admin_views/templates/views/layouts/_sidebar.html.erb +15 -0
  13. data/generators/admin_views/templates/views/layouts/admin.html.erb +28 -0
  14. data/generators/admin_views/templates/views/layouts/modal.html.erb +14 -0
  15. data/generators/admin_views/templates/views/{_form.html.erb → model/_form.html.erb} +8 -4
  16. data/generators/admin_views/templates/views/model/edit.html.erb +4 -0
  17. data/generators/admin_views/templates/views/model/index.html.erb +54 -0
  18. data/generators/admin_views/templates/views/model/new.html.erb +4 -0
  19. data/generators/admin_views/templates/views/model/show.html.erb +16 -0
  20. metadata +18 -7
  21. data/generators/admin_views/templates/controllers/controller.rb +0 -87
  22. data/generators/admin_views/templates/views/edit.html.erb +0 -3
  23. data/generators/admin_views/templates/views/index.html.erb +0 -33
  24. data/generators/admin_views/templates/views/new.html.erb +0 -3
  25. data/generators/admin_views/templates/views/show.html.erb +0 -11
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Admin Views
2
2
  =================
3
3
 
4
- A Rails generator to create admin scaffolding for a model.
4
+ A Rails generator to create admin scaffolding with searching and sorting for a model.
5
5
 
6
6
  The generator is pretty opinionated, because I wrote this after I became tired of writing the same
7
7
  code over and over. It expects that your admin controllers will reside under app/controllers/admin and
@@ -3,29 +3,32 @@ require 'active_support/inflector'
3
3
  class AdminViewsGenerator < Rails::Generator::NamedBase
4
4
  include ActiveSupport::Inflector
5
5
 
6
- attr_reader :model_class, :model_name, :model_plural, :columns
6
+ attr_reader :model_class, :model_name, :plural_name, :columns
7
7
 
8
8
  def initialize(runtime_args, runtime_options = {})
9
9
  super
10
10
 
11
- @model_class = name
12
- @model_name = underscore(@model_class)
13
- @model_plural = underscore(pluralize(@model_class))
14
- @columns = Object.const_get(@model_class).columns
11
+ #@model_class = name
12
+ #@model_human = name.underscore.humanize
13
+ #@model_name = @model_class.underscore
14
+
15
+ @columns = Object.const_get(name).columns
15
16
  end
16
17
 
17
18
  def manifest
18
19
  record do |m|
19
20
  m.directory("app/controllers/admin")
20
- m.template('controllers/controller.rb', "app/controllers/admin/#{model_plural}_controller.rb")
21
-
22
- m.directory("app/views/admin/#{model_plural}")
23
- m.template('views/_form.html.erb', "app/views/admin/#{model_plural}/_form.html.erb")
24
- m.template('views/_model.html.erb', "app/views/admin/#{model_plural}/_#{model_name}.html.erb")
25
- m.template('views/edit.html.erb', "app/views/admin/#{model_plural}/edit.html.erb")
26
- m.template('views/index.html.erb', "app/views/admin/#{model_plural}/index.html.erb")
27
- m.template('views/new.html.erb', "app/views/admin/#{model_plural}/new.html.erb")
28
- m.template('views/show.html.erb', "app/views/admin/#{model_plural}/show.html.erb")
21
+ m.template('controllers/model_controller.rb', "app/controllers/admin/#{plural_name}_controller.rb")
22
+
23
+ m.directory("app/helpers/admin")
24
+ m.template('helpers/admin_view_helper.rb', "app/helpers/admin/admin_view_helper.rb")
25
+
26
+ m.directory("app/views/admin/#{plural_name}")
27
+ m.template('views/model/_form.html.erb', "app/views/admin/#{plural_name}/_form.html.erb")
28
+ m.template('views/model/edit.html.erb', "app/views/admin/#{plural_name}/edit.html.erb")
29
+ m.template('views/model/index.html.erb', "app/views/admin/#{plural_name}/index.html.erb")
30
+ m.template('views/model/new.html.erb', "app/views/admin/#{plural_name}/new.html.erb")
31
+ m.template('views/model/show.html.erb', "app/views/admin/#{plural_name}/show.html.erb")
29
32
  end
30
33
  end
31
34
  end
@@ -0,0 +1,21 @@
1
+ class Admin::AdminController < ApplicationController
2
+ before_filter :admin_required
3
+ layout 'admin/layouts/admin'
4
+
5
+ protected
6
+ def admin_required
7
+ unless current_user && current_user.admin?
8
+ flash[:notice] = "You do not have permission to do that."
9
+ redirect_to root_url
10
+ end
11
+ end
12
+
13
+ def order_sql(params)
14
+ if params[:order]
15
+ split = params[:order].split("_")
16
+ order = split.last.upcase
17
+ column = split[0..-2].join("_")
18
+ "#{column} #{order}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ class Admin::DashboardController < Admin::AdminController
2
+ helper_method :output_graph
3
+
4
+ def index
5
+ plot(Users)
6
+ end
7
+
8
+ protected
9
+ def plot(klass)
10
+ models = klass.find(:all,
11
+ :select => "*, count(*) AS count",
12
+ :group => "DATE_FORMAT(created_at,'%y-%m-%d')"
13
+ )
14
+
15
+ series = TimeFlot.new do |f|
16
+ f.series_for(klass.to_s, cumulative(models), :x => :created_at, :y => :count)
17
+ end
18
+ eval("@#{klass.to_s.underscore}_flot = series")
19
+ @flot_plots ||= []
20
+ @flot_plots << {:name =>, :plot => }
21
+ end
22
+
23
+ def cumulative(models)
24
+ total = 0
25
+ models.each {|a| total = a.count = a.count.to_i + total }
26
+ end
27
+ end
@@ -0,0 +1,65 @@
1
+ class Admin::<%= name.pluralize %>Controller < Admin::AdminController
2
+ helper 'admin/admin_view'
3
+
4
+ # GET /admin/<%= plural_name %>
5
+ def index
6
+ if params[:search]
7
+ sql, sql_params = [], []
8
+ # By default searches all text fields
9
+ <% search_cols = columns.find_all {|col| [:text, :string].include?(col.type) }.collect {|col| "'#{col.name}'" }.join(",") -%>
10
+ [<%= search_cols %>].each do |col|
11
+ sql << "#{col} LIKE ?"
12
+ sql_params << "%#{params[:search]}%"
13
+ end
14
+ conditions = [sql.join(" OR "), sql_params].flatten
15
+ @<%= plural_name %> = <%= name %>.paginate(:all, :page => params[:page], :conditions => conditions, :order => order_sql(params))
16
+ else
17
+ @<%= plural_name %> = <%= name %>.paginate(:all, :page => params[:page], :order => order_sql(params))
18
+ end
19
+ end
20
+
21
+ # GET /admin/<%= plural_name %>/1
22
+ def show
23
+ @<%= singular_name %> = <%= name %>.find(params[:id])
24
+ end
25
+
26
+ # GET /admin/<%= plural_name %>/new
27
+ def new
28
+ @<%= singular_name %> = <%= name %>.new
29
+ end
30
+
31
+ # GET /admin/<%= plural_name %>/1/edit
32
+ def edit
33
+ @<%= singular_name %> = <%= name %>.find(params[:id])
34
+ end
35
+
36
+ # POST /admin/<%= plural_name %>
37
+ def create
38
+ @<%= singular_name %> = <%= name %>.new(params[:<%= singular_name %>])
39
+
40
+ if @<%= singular_name %>.save
41
+ redirect_to(admin_<%= singular_name %>_url(@<%= singular_name %>), :notice => '<%= class_name %> was successfully created.')
42
+ else
43
+ render :action => "new"
44
+ end
45
+ end
46
+
47
+ # PUT /admin/<%= plural_name %>/1
48
+ def update
49
+ @<%= singular_name %> = <%= name %>.find(params[:id])
50
+
51
+ if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
52
+ redirect_to(admin_<%= singular_name %>_url(@<%= singular_name %>), :notice => '<%= name %> was successfully updated.')
53
+ else
54
+ render :action => "edit"
55
+ end
56
+ end
57
+
58
+ # DELETE /admin/<%= plural_name %>/1
59
+ def destroy
60
+ @<%= singular_name %> = <%= name %>.find(params[:id])
61
+ @<%= singular_name %>.destroy
62
+
63
+ redirect_to(admin_<%= plural_name %>_url)
64
+ end
65
+ end
@@ -0,0 +1,22 @@
1
+ module Admin::AdminViewHelper
2
+ def order_param(col_name)
3
+ order = params[:order]
4
+
5
+ if order == "#{col_name}_asc"
6
+ "#{col_name}_desc"
7
+ elsif order == "#{col_name}_desc"
8
+ "#{col_name}_asc"
9
+ else
10
+ "#{col_name}_asc"
11
+ end
12
+ end
13
+
14
+ def order_sql(params)
15
+ if params[:order]
16
+ split = params[:order].split("_")
17
+ order = split.last.upcase
18
+ column = split[0..-2].join("_")
19
+ "#{column} #{order}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ <% content_for :header do %>
2
+ <%= flot_includes(:jquery => false) %>
3
+ <% end %>
4
+
5
+ <div class="title">
6
+ <h2>Dashboard</h2>
7
+ </div>
8
+
9
+ <div class="box" style="min-height: 400px;">
10
+ <% @flot_plots.each do |flot| %>
11
+ <h4><%= flot[:name]%></h4>
12
+ <%= flot_canvas(flot[:name].underscore, :style => "width: 400px; height: 200px;") %>
13
+ <% flot_graph(flot[:name].underscore, flot[:plot]) do %>
14
+ <%= flot_plot %>
15
+ <% end %>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,4 @@
1
+ <div id="header">
2
+ <h1><%= link_to 'Admin', admin_root_path, :class => "main_section_link" %></h1>
3
+ <div class="menu">Welcome <%= link_to current_user.email %> | <%= link_to 'Public Site', root_path %> | <%= link_to 'Log Out', user_session_path, :method => :delete %></div>
4
+ </div>
@@ -0,0 +1,15 @@
1
+ <div id="sidebar">
2
+ <div class="title">
3
+ <h2>Navigation</h2>
4
+ </div>
5
+ <div class="navigation">
6
+ <ul>
7
+ <li class='<%= check_active_nav(%r{/dashboard}) %>'><%= link_to 'Dashboard', admin_dashboard_path %></li>
8
+ <li class='<%= check_active_nav(%r{/users}) %>'><%= link_to 'Users', admin_users_path %></li>
9
+ <ul>
10
+ <li><%= link_to 'More', admin_users_path %></li>
11
+ </ul>
12
+ </li>
13
+ </ul>
14
+ </div>
15
+ </div>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="content-Type" content="text/html;charset=utf-8" />
5
+ <title>Admin</title>
6
+ <%= stylesheet_link_tag ['admin','formtastic', 'formtastic_changes'] %>
7
+ <%= javascript_include_tag ['jquery','jquery-ui','jrails','minmax'] %>
8
+ <%= yield :header %>
9
+ </head>
10
+ <body>
11
+ <%= render :partial => "admin/layouts/header" %>
12
+
13
+ <div id="wrapper">
14
+ <%= render :partial => "admin/layouts/sidebar" %>
15
+ <div id="content">
16
+ <% for type, message in flash %>
17
+ <div id="<%= type %>"><strong><%= type.to_s.humanize %></strong>: <%= message %></div>
18
+ <% end %>
19
+ <% if @breadcrumbs %>
20
+ <div id="breadcrumbs" style="float: right; padding-right: 20px;">
21
+ <%= link_to 'Users', admin_users_path %> > Create
22
+ </div>
23
+ <% end %>
24
+ <%= yield %>
25
+ </div>
26
+ </div>
27
+ </body>
28
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="content-Type" content="text/html;charset=utf-8" />
5
+ <title>Pushkart Scoring Server</title>
6
+ <%= stylesheet_link_tag ['login','form'] %>
7
+ <%= yield :header %>
8
+ </head>
9
+ <body>
10
+ <div id="box">
11
+ <%= yield %>
12
+ </div>
13
+ </body>
14
+ </html>
@@ -1,8 +1,12 @@
1
- <%% semantic_form_for [:admin, @<%= model_name %>] do |form| %>
1
+ <%% semantic_form_for [:admin, @<%= singular_name %>] do |form| %>
2
+ <%%= form.inputs %>
3
+
4
+ <%%= form.buttons :commit %>
5
+ <%% end %>
6
+
7
+ <!-- Here are the fields separated out
2
8
  <% # http://github.com/justinfrench/formtastic %>
3
9
  <% for col in columns -%>
4
10
  <%%= form.input :<%= col.name %> -%>
5
11
  <% end -%>
6
-
7
- <%%= form.buttons :commit %>
8
- <%% end %>
12
+ -->
@@ -0,0 +1,4 @@
1
+ <h2>Edit <%= singular_name.humanize %></h2>
2
+ <div class="box">
3
+ <%%= render :partial => "form" %>
4
+ </div>
@@ -0,0 +1,54 @@
1
+ <%% content_for :header do %>
2
+ <%%= stylesheet_link_tag 'admin/table' %>
3
+ <%% end %>
4
+
5
+ <div class="title">
6
+ <h2><%= singular_name.humanize.pluralize %></h2>
7
+ </div>
8
+
9
+ <div class="box">
10
+ <div id="actions">
11
+ <div style="float: right;">
12
+ <form method="get" style="margin-top: -5px;">
13
+ <%%= text_field_tag 'search', params[:search], :class => 'search-input' %>
14
+ <%%= submit_tag "Search" %>
15
+ </form>
16
+ </div>
17
+ <%%= link_to "Create New <%= name %>", new_admin_<%= singular_name %>_path %>
18
+ </div>
19
+ <table>
20
+
21
+ <table>
22
+ <thead>
23
+ <tr>
24
+ <% columns.each do |col| -%>
25
+ <th><%%= link_to '<%= col.human_name %>', params.merge(:order => order_param('<%= col.name %>')) %></th>
26
+ <% end -%>
27
+ <th></th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>
31
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
32
+ <tr id="<%= singular_name %>_<%%= <%= singular_name %>.id %>">
33
+ <td><%%= link_to <%= singular_name %>.id, admin_<%= singular_name %>_path(<%= singular_name %>) %></td>
34
+ <% columns.find_all {|col| col.name != "id" }.each do |col| -%>
35
+ <% next if [:binary, :text].include? col.type -%>
36
+ <% if [:datetime, :date].include? col.type -%>
37
+ <td><%%= h <%= singular_name %>.<%= col.name %>.to_formatted_s(:short) if <%= singular_name %>.<%= col.name %> %></td>
38
+ <% elsif [:string].include? col.type -%>
39
+ <td><%%= h truncate(<%= singular_name %>.<%= col.name %>, :length => 20) %></td>
40
+ <% else %>
41
+ <td><%%= h <%= singular_name %>.<%= col.name %> %></td>
42
+ <% end -%>
43
+ <% end -%>
44
+ <td>
45
+ <%%= link_to "Edit", edit_admin_<%= singular_name %>_path(<%= singular_name %>) %>
46
+ <%%= link_to "Delete", admin_<%= singular_name %>_path(<%= singular_name %>), :method => :delete, :confirm => "Are you sure?" %>
47
+ </td>
48
+ </tr>
49
+ <%% end -%>
50
+ </tbody>
51
+ </table>
52
+ </div>
53
+
54
+ <%%= will_paginate @<%= plural_name %> %>
@@ -0,0 +1,4 @@
1
+ <h2>Create New <%= singular_name.humanize %></h2>
2
+ <div class="box">
3
+ <%%= render :partial => "form" %>
4
+ </div>
@@ -0,0 +1,16 @@
1
+ <%% content_for :header do %>
2
+ <%%= stylesheet_link_tag 'admin/table' %>
3
+ <%% end %>
4
+
5
+ <h2><%= singular_name.humanize %> <%%= @<%= singular_name %>.id %></h2>
6
+ <div class="box">
7
+ <div id="actions" style="float: right;">
8
+ <%%= link_to "Show All <%= singular_name.humanize.pluralize %>", admin_<%= plural_name %>_path %>
9
+ <%%= link_to "Edit <%= model_class %>", edit_admin_<%= singular_name %>_path(@<%= singular_name %>) %>
10
+ </div>
11
+ <table>
12
+ <% for col in columns -%>
13
+ <tr><td><%= col.human_name %></td><td><%%= h @<%= singular_name %>.<%= col.name %> %></td></tr>
14
+ <% end -%>
15
+ </table>
16
+ </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin_views
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conor Hunt
@@ -45,12 +45,23 @@ files:
45
45
  - LICENSE
46
46
  - Changelog
47
47
  - generators/admin_views/admin_views_generator.rb
48
- - generators/admin_views/templates/controllers/controller.rb
49
- - generators/admin_views/templates/views/_form.html.erb
50
- - generators/admin_views/templates/views/edit.html.erb
51
- - generators/admin_views/templates/views/index.html.erb
52
- - generators/admin_views/templates/views/new.html.erb
53
- - generators/admin_views/templates/views/show.html.erb
48
+ - generators/admin_views/templates/controllers/admin_controller.rb
49
+ - generators/admin_views/templates/controllers/dashboard_controller.rb
50
+ - generators/admin_views/templates/controllers/model_controller.rb
51
+ - generators/admin_views/templates/helpers/admin_view_helper.rb
52
+ - generators/admin_views/templates/stylesheets/admin.css
53
+ - generators/admin_views/templates/stylesheets/formtastic-changes.css
54
+ - generators/admin_views/templates/stylesheets/table.css
55
+ - generators/admin_views/templates/views/dashboard/index.html.erb
56
+ - generators/admin_views/templates/views/layouts/_header.html.erb
57
+ - generators/admin_views/templates/views/layouts/_sidebar.html.erb
58
+ - generators/admin_views/templates/views/layouts/admin.html.erb
59
+ - generators/admin_views/templates/views/layouts/modal.html.erb
60
+ - generators/admin_views/templates/views/model/_form.html.erb
61
+ - generators/admin_views/templates/views/model/edit.html.erb
62
+ - generators/admin_views/templates/views/model/index.html.erb
63
+ - generators/admin_views/templates/views/model/new.html.erb
64
+ - generators/admin_views/templates/views/model/show.html.erb
54
65
  has_rdoc: true
55
66
  homepage: http://github.com/conorh/admin_views
56
67
  licenses: []
@@ -1,87 +0,0 @@
1
- class Admin::<%= pluralize(model_class) %>Controller < Admin::AdminController
2
- helper_method :order_param
3
-
4
- # GET /admin/<%= model_plural %>
5
- def index
6
- if params[:search]
7
- sql, sql_params = [], []
8
- # By default searches all text fields
9
- <% search_cols = columns.find_all {|col| [:text, :string].include?(col.type) }.collect {|col| "'#{col.name}'" }.join(",") -%>
10
- [<%= search_cols %>].each do |col|
11
- sql << "#{col} LIKE ?"
12
- sql_params << "%#{params[:search]}%"
13
- end
14
- conditions = [sql.join(" OR "), sql_params].flatten
15
- @<%= model_plural %> = <%= model_class %>.paginate(:all, :page => params[:page], :conditions => conditions, :order => order_sql(params))
16
- else
17
- @<%= model_plural %> = <%= model_class %>.paginate(:all, :page => params[:page], :order => order_sql(params))
18
- end
19
- end
20
-
21
- # GET /admin/<%= model_plural %>/1
22
- def show
23
- @<%= model_name %> = <%= model_class %>.find(params[:id])
24
- end
25
-
26
- # GET /admin/<%= model_plural %>/new
27
- def new
28
- @<%= model_name %> = <%= model_class %>.new
29
- end
30
-
31
- # GET /admin/<%= model_plural %>/1/edit
32
- def edit
33
- @<%= model_name %> = <%= model_class %>.find(params[:id])
34
- end
35
-
36
- # POST /admin/<%= model_plural %>
37
- def create
38
- @<%= model_name %> = <%= model_class %>.new(params[:<%= model_name %>])
39
-
40
- if @<%= model_name %>.save
41
- redirect_to(@<%= model_name %>, :notice => '<%= class_name %> was successfully created.')
42
- else
43
- render :action => "new"
44
- end
45
- end
46
-
47
- # PUT /admin/<%= model_plural %>/1
48
- def update
49
- @<%= model_name %> = <%= model_class %>.find(params[:id])
50
-
51
- if @<%= model_name %>.update_attributes(params[:<%= model_name %>])
52
- redirect_to(admin_<%= model_plural %>_url(@<%= model_name %>), :notice => '<%= model_class %> was successfully updated.')
53
- else
54
- render :action => "edit"
55
- end
56
- end
57
-
58
- # DELETE /admin/<%= model_plural %>/1
59
- def destroy
60
- @<%= model_name %> = <%= model_class %>.find(params[:id])
61
- @<%= model_name %>.destroy
62
-
63
- redirect_to(admin_<%= model_plural %>_url)
64
- end
65
-
66
- private
67
- def order_sql(params)
68
- if params[:order]
69
- split = params[:order].split("_")
70
- order = split.last.upcase
71
- column = split[0..-2].join("_")
72
- "#{column} #{order}"
73
- end
74
- end
75
-
76
- def order_param(col_name)
77
- order = params[:order]
78
-
79
- if order == "#{col_name}_asc"
80
- "#{col_name}_asc"
81
- elsif order == "#{col_name}_desc"
82
- "#{col_name}_desc"
83
- else
84
- "#{col_name}_asc"
85
- end
86
- end
87
- end
@@ -1,3 +0,0 @@
1
- <h2>Edit <%= model_class %></h2>
2
-
3
- <%%= render :partial => "form" %>
@@ -1,33 +0,0 @@
1
- <div id="create-link" style="float: right; font-size: 1.2em; font-weight: bold">
2
- <%%= link_to "Create New <%= model_class %>", new_admin_<%= model_name %>_path %>
3
- </div>
4
-
5
- <div id="search">
6
- <form method="get">
7
- <%%= text_field_tag 'search', params[:search] %>
8
- <%%= submit_tag "Search" %>
9
- </form>
10
- </div>
11
-
12
- <h2><%= model_class %></h2>
13
- <table>
14
- <tr>
15
- <% columns.each do |col| -%>
16
- <th><%%= link_to '<%= col.human_name %>', params.merge(:order => order_param('<%= col.name %>')) %></th>
17
- <% end -%>
18
- <th></th>
19
- </tr>
20
- <%% @<%= model_plural %>.each do |<%= model_name %>| %>
21
- <tr id="<%= model_name %>_<%%= <%= model_name %>.id %>">
22
- <% columns.each do |col| -%>
23
- <td><%%= h <%= model_name %>.<%= col.name %> %></td>
24
- <% end -%>
25
- <td>
26
- <%%= link_to "Edit", edit_admin_<%= model_name %>_path(<%= model_name %>) %>
27
- <%%= link_to "Delete", admin_<%= model_name %>_path(<%= model_name %>), :method => :delete, :confirm => "Are you sure?" %>
28
- </td>
29
- </tr>
30
- <%% end -%>
31
- </table>
32
-
33
- <%%= will_paginate @<%= model_plural %> %>
@@ -1,3 +0,0 @@
1
- <h2>Create New <%= model_class %></h2>
2
-
3
- <%%= render :partial => "form" %>
@@ -1,11 +0,0 @@
1
- <h2><%= model_class %> <%%= @<%= model_name %>.id %></h2>
2
- <div id="create-link" style="float: right; font-size: 1.2em; font-weight: bold">
3
- <%%= link_to "Show All <%= pluralize(model_class) %>", admin_<%= model_plural %>_path %>
4
- <%%= link_to "Edit <%= model_class %>", edit_admin_<%= model_name %>_path(@<%= model_name %>) %>
5
- </div>
6
-
7
- <table>
8
- <% for col in columns -%>
9
- <tr><td><%= col.human_name %></td><td><%%= h @<%= model_name %>.<%= col.name %> %></td></tr>
10
- <% end -%>
11
- </table>