Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

-

  • Loading branch information...
commit c14913faf5a6e412cc65ee2b476e46ed5512e223 1 parent 0131117
Jason Lee authored November 18, 2011
25  README.md
Source Rendered
... ...
@@ -0,0 +1,25 @@
  1
+这个是我对 Rails 默认模板的定制,模板乃是个人喜好,不一定适合你,仅供查考。此模板用于帮助我们快速生成管理后台得 CRUD 功能。 
  2
+
  3
+## 需要得组件
  4
+
  5
+* Rails 3.1
  6
+* [wice_grid](https://github.com/justinfrench/formtastic)
  7
+* [simple_form](https://github.com/plataformatec/simple_form)
  8
+
  9
+## 安装
  10
+
  11
+    $ cd ~/Downloads
  12
+    $ git clone git://github.com/huacnlee/rails_templates.git
  13
+    $ cp -R rails_templates/* ~/you_rails_project/lib/
  14
+    
  15
+## 使用用法
  16
+
  17
+你可以根据自己得喜好修改模板,然后用 Rails scaffold generator 生成
  18
+
  19
+    $ rails g scaffold Post title:string category_id:integer body:text
  20
+    $ rails g scaffold admin/posts title:string category_id:integer body:text
  21
+    $ rails g scaffold_controller admin/posts title:string category_id:integer body:text
  22
+
  23
+
  24
+Enjoy!
  25
+
13  README.rdoc
Source Rendered
... ...
@@ -1,13 +0,0 @@
1  
-这个是我对 Rails 默认模板的定制,模板乃是个人喜好,不一定适合你,仅供查考。
2  
-
3  
-如果你想试试,那么下载,并将他们放进你 Rails 项目的 lib 目录,如:homeland/lib
4  
-
5  
-然后使用
6  
-
7  
- rails g scaffold Post title:string category_id:integer body:text
8  
- rails g scaffold admin/posts title:string category_id:integer body:text
9  
-
10  
-来生成试试。
11  
-
12  
-这个需要 wice_grid[https://github.com/justinfrench/formtastic] 和 simple_form[https://github.com/plataformatec/simple_form] 这两个 Rails 插件。
13  
-
2  templates/erb/scaffold/_form.html.erb
@@ -8,7 +8,7 @@
8 8
 <% end -%>
9 9
   </div>
10 10
   <div class="actions">
11  
-    <%%= f.submit "提交", :class => "button" %> 或者 <%%= link_to '返回', <%= index_helper %>_path %>
  11
+    <%%= f.submit "提交", :class => "btn primary" %> 或者 <%%= link_to '返回', <%= index_helper %>_path %>
12 12
   </div>
13 13
 <%% end %>
14 14
 </div>
4  templates/erb/scaffold/index.html.erb
@@ -3,8 +3,8 @@
3 3
 <%% end %>
4 4
 <%%= render 'base' %>
5 5
 <div class="tools">
6  
-  <a href="<%%= <%= plural_table_name %>_path %>" class="button">查看所有</a>
7  
-  <a href="<%%= new_<%= singular_table_name %>_path %>" class="button">新建</a>
  6
+  <a href="<%%= <%= plural_table_name %>_path %>" class="btn small">查看所有</a>
  7
+  <a href="<%%= new_<%= singular_table_name %>_path %>" class="btn small success">新建</a>
8 8
 </div>
9 9
 
10 10
 <div id="<%= plural_table_name %>">
6  templates/rails/scaffold_controller/controller.rb
... ...
@@ -1,10 +1,8 @@
1 1
 # coding: UTF-8
2  
-class <%= controller_class_name %>Controller < ApplicationController
  2
+class <%= controller_class_name %>Controller < <%= controller_class_name.include?('::') == true ? "#{controller_class_name.split('::').first}::" : ''  %>ApplicationController
3 3
   
4 4
   def index
5  
-    @<%= plural_file_name %> = initialize_grid(<%= file_name.camelize %>, 
6  
-      :order => 'id',
7  
-      :order_direction => 'desc')
  5
+    @<%= plural_file_name %> = <%= file_name.camelize %>.recent.paginate(:page => params[:page], :per_page => 20)
8 6
 
9 7
     respond_to do |format|
10 8
       format.html # index.html.erb

0 notes on commit c14913f

Please sign in to comment.
Something went wrong with that request. Please try again.