public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Search Repo:
Click here to lend your support to: mack and make a donation at www.pledgie.com !
Updated ScaffoldGenerator to not include created_at or updated_at fields 
for edit/new pages.
markbates (author)
Fri Apr 18 13:51:43 -0700 2008
commit  1c9f6ec4d57c62a8fdfab9d7166271304499b3a2
tree    0f4a44bcb2f81850a0f045df39526cf766941e1f
parent  4da6e69f7d9a0a6f3df04cc6b36e054d8ca0d26e
...
32
33
34
35
 
36
37
38
...
32
33
34
 
35
36
37
38
0
@@ -32,7 +32,7 @@ module Mack
0
       # Raise Mack::Errors::RequiredGeneratorParameterMissing if a required parameter
0
       # is missing.
0
       def initialize(env = {})
0
- @env = env
0
+ @env = env.to_hash
0
         self.class.required_params.each do |p|
0
           raise Mack::Errors::RequiredGeneratorParameterMissing.new(p) unless param(p)
0
         end
...
47
48
49
50
 
51
52
53
...
47
48
49
 
50
51
52
53
0
@@ -47,7 +47,7 @@ class ScaffoldGenerator < Mack::Generator::Base
0
       template(File.join(temp_dir, "generic", "app", "views", "edit.html.erb.template"), File.join(app_views_dir, "edit.html.erb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "new.html.erb.template"), File.join(app_views_dir, "new.html.erb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "show.html.erb.template"), File.join(app_views_dir, "show.html.erb"), :force => param(:force))
0
- ModelGenerator.new("NAME" => param(:name)).run
0
+ ModelGenerator.new(@env).run
0
     else
0
       template(File.join(temp_dir, "no_orm", "app", "controllers", "controller.rb.template"), File.join(app_cont_dir, "#{@name_plural}_controller.rb"), :force => param(:force))
0
     end
...
5
6
7
 
8
9
10
11
12
 
13
14
15
...
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -5,11 +5,13 @@
0
 <form action="<%%= <%= @name_singular %>s_update_url(:id => @<%= @name_singular %>.id) %>" class="edit_<%= @name_singular %>" id="edit_<%= @name_singular %>" method="<%= @name_singular %>">
0
   <input type="hidden" name="_method" value="put">
0
 <% for column in columns -%>
0
+<% unless column.column_name == "created_at" || column.column_name == "updated_at" -%>
0
   <p>
0
     <b><%= column.column_name.singular.camelcase %></b><br />
0
     <%= column.form_field %>
0
   </p>
0
 <% end -%>
0
+<% end -%>
0
   <p>
0
     <input id="<%= @name_singular %>_submit" name="commit" type="submit" value="Create" />
0
   </p>
...
4
5
6
 
7
8
9
10
11
 
12
13
14
...
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -4,11 +4,13 @@
0
 
0
 <form action="<%%= <%= @name_singular %>s_create_url %>" class="new_<%= @name_singular %>" id="new_<%= @name_singular %>" method="<%= @name_singular %>">
0
 <% for column in columns -%>
0
+<% unless column.column_name == "created_at" || column.column_name == "updated_at" -%>
0
   <p>
0
     <b><%= column.column_name.singular.camelcase %></b><br />
0
     <%= column.form_field %>
0
   </p>
0
 <% end -%>
0
+<% end -%>
0
   <p>
0
     <input id="<%= @name_singular %>_submit" name="commit" type="submit" value="Create" />
0
   </p>
...
212
213
214
215
 
216
217
218
...
249
250
251
 
 
252
253
254
255
256
257
 
 
258
259
260
...
304
305
306
 
 
 
 
 
 
 
 
307
308
309
...
212
213
214
 
215
216
217
218
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
...
308
309
310
311
312
313
314
315
316
317
318
319
320
321
0
@@ -212,7 +212,7 @@ CONT
0
   private
0
   
0
   def orm_common_with_cols
0
- sg = ScaffoldGenerator.new("name" => "zoo", "cols" => "name:string,description:text")
0
+ sg = ScaffoldGenerator.new("name" => "zoo", "cols" => "name:string,description:text,created_at:datetime,updated_at:datetime")
0
     sg.run
0
     File.open(File.join(MACK_CONFIG, "routes.rb")) do |f|
0
       assert_match "r.resource :zoos # Added by rake generate:scaffold name=zoo", f.read
0
@@ -249,12 +249,16 @@ ERB
0
   <tr>
0
     <th>Name</th>
0
     <th>Description</th>
0
+ <th>CreatedAt</th>
0
+ <th>UpdatedAt</th>
0
   </tr>
0
 
0
 <% for zoo in @zoos %>
0
   <tr>
0
     <td><%= zoo.name %></td>
0
     <td><%= zoo.description %></td>
0
+ <td><%= zoo.created_at %></td>
0
+ <td><%= zoo.updated_at %></td>
0
     <td><%= link_to("Show", zoos_show_url(:id => zoo.id)) %></td>
0
     <td><%= link_to("Edit", zoos_edit_url(:id => zoo.id)) %></td>
0
     <td><%= link_to("Delete", zoos_delete_url(:id => zoo.id), :method => :delete, :confirm => "Are you sure?") %></td>
0
@@ -304,6 +308,14 @@ ERB
0
   <b>Description</b><br />
0
   <%= @zoo.description %>
0
 </p>
0
+<p>
0
+ <b>CreatedAt</b><br />
0
+ <%= @zoo.created_at %>
0
+</p>
0
+<p>
0
+ <b>UpdatedAt</b><br />
0
+ <%= @zoo.updated_at %>
0
+</p>
0
 
0
 <%= link_to("Edit", zoos_edit_url(:id => @zoo.id)) %> |
0
 <%= link_to("Back", zoos_index_url) %>

Comments

    No one has commented yet.