norman-randomba_scaffold 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,81 @@
1
+ h1. Randomba Scaffold
2
+
3
+ A collection of hacks to the Rails scaffold generator, to make it output code
4
+ the way I use it in my projects. You may like some of it, and may hate other
5
+ parts. You're free to use it under the terms of the MIT license if the parts
6
+ you like outweigh the parts you hate.
7
+
8
+ This scaffold generator does the same thing as the default Rails scaffold
9
+ generator, with a few differences.
10
+
11
+ h2. Differences from Rails Scaffolding:
12
+
13
+ h3. Controller
14
+
15
+ * Loads object with a before_filter to be DRYer.
16
+ * Adds placeholder permission checking before_filters on all actions.
17
+ * "Destroy" method handles error conditions.
18
+ * Actions are alphabetized for more obvious consistency.
19
+
20
+ h3. Controller Test
21
+
22
+ * Tests error conditions, not just the "happy-path."
23
+ * Has 100% code coverage with RCov.
24
+ * Simplifies test method names and alphabetizes them for more obvious consistency.
25
+ * Uses some very simple mocking with mocha to limit calls to the DB.
26
+
27
+ h3. Views
28
+
29
+ * Have cleaner, more semantic XHTML.
30
+ * Are broken up into a couple of partials to be DRYer.
31
+ * Use will_paginate.
32
+
33
+ h3. Misc
34
+
35
+ * Doesn't generate a layout or CSS file.
36
+
37
+ h2. Installation
38
+
39
+ There are three ways you can install this generator:
40
+
41
+ h3. Gem
42
+
43
+ @sudo gem install norman-randomba-scaffold@
44
+
45
+ - or -
46
+
47
+ <pre>
48
+ <code>
49
+ git clone git://github.com/norman/randomba-scaffold.git
50
+ cd randomba-scaffold
51
+ gem build randomba_scaffold.gemspec
52
+ sudo gem install randomba_scaffold-*.gem
53
+ </code>
54
+ </pre>
55
+
56
+ h3. Manual
57
+
58
+ Download the tarball from the Github repository and unarchive it in ~/.rails/generators.
59
+
60
+ h3. Plugin
61
+
62
+ @./script/plugin install git://github.com/norman/randomba-scaffold.git@
63
+
64
+
65
+
66
+ h2. Dependencies
67
+
68
+ The generated code will depend on:
69
+
70
+ * "will_paginate":http://github.com/mislav/will_paginate/
71
+ * "mocha":http://mocha.rubyforge.org/
72
+
73
+ You'll need to add the gems and or requires to your config/environment.rb
74
+ manually.
75
+
76
+ h2. Author
77
+
78
+ "Norman Clarke":mailto:norman@randomba.org
79
+
80
+ This work is derived from code in "Ruby on Rails":http://rubyonrails.org/ and
81
+ is released under its same license, the MIT License.
@@ -0,0 +1,98 @@
1
+ class RandombaScaffoldGenerator < Rails::Generator::NamedBase
2
+ default_options :skip_timestamps => false, :skip_migration => false
3
+
4
+ attr_reader :controller_name,
5
+ :controller_class_path,
6
+ :controller_file_path,
7
+ :controller_class_nesting,
8
+ :controller_class_nesting_depth,
9
+ :controller_class_name,
10
+ :controller_underscore_name,
11
+ :controller_singular_name,
12
+ :controller_plural_name
13
+ alias_method :controller_file_name, :controller_underscore_name
14
+ alias_method :controller_table_name, :controller_plural_name
15
+
16
+ def initialize(runtime_args, runtime_options = {})
17
+ super
18
+
19
+ @controller_name = @name.pluralize
20
+
21
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
22
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
23
+ @controller_singular_name=base_name.singularize
24
+ if @controller_class_nesting.empty?
25
+ @controller_class_name = @controller_class_name_without_nesting
26
+ else
27
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
28
+ end
29
+ end
30
+
31
+ def manifest
32
+ record do |m|
33
+
34
+ # Check for class naming collisions.
35
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
36
+ m.class_collisions(class_path, "#{class_name}")
37
+
38
+ # Controller, helper, views, test and stylesheets directories.
39
+ m.directory(File.join('app/models', class_path))
40
+ m.directory(File.join('app/controllers', controller_class_path))
41
+ m.directory(File.join('app/helpers', controller_class_path))
42
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
43
+ m.directory(File.join('test/functional', controller_class_path))
44
+ m.directory(File.join('test/unit', class_path))
45
+
46
+ for action in scaffold_views
47
+ m.template(
48
+ "view_#{action}.html.erb",
49
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb")
50
+ )
51
+ end
52
+
53
+ m.template(
54
+ "_form.html.erb",
55
+ File.join('app/views', controller_class_path, controller_file_name, "_form.html.erb")
56
+ )
57
+
58
+ m.template(
59
+ "_object.html.erb",
60
+ File.join('app/views', controller_class_path, controller_file_name, "_#{name}.html.erb")
61
+ )
62
+
63
+ m.template(
64
+ 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
65
+ )
66
+
67
+ m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
68
+ m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
69
+
70
+ m.route_resources controller_file_name
71
+
72
+ m.dependency 'model', [name] + @args, :collision => :skip
73
+ end
74
+ end
75
+
76
+ protected
77
+ # Override with your own usage banner.
78
+ def banner
79
+ "Usage: #{$0} scaffold ModelName [field:type, field:type]"
80
+ end
81
+
82
+ def add_options!(opt)
83
+ opt.separator ''
84
+ opt.separator 'Options:'
85
+ opt.on("--skip-timestamps",
86
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
87
+ opt.on("--skip-migration",
88
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
89
+ end
90
+
91
+ def scaffold_views
92
+ %w[ index show new edit ]
93
+ end
94
+
95
+ def model_name
96
+ class_name.demodulize
97
+ end
98
+ end
@@ -0,0 +1,15 @@
1
+ <%% form_for(<%= singular_name %>) do |f| %>
2
+
3
+ <%%= f.error_messages %>
4
+ <% for attribute in attributes %>
5
+ <p>
6
+ <%%= f.label :<%= attribute.name %> %><br />
7
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
8
+ </p>
9
+ <% end -%>
10
+
11
+ <p>
12
+ <%%= f.submit "Submit" %>
13
+ </p>
14
+
15
+ <%% end %>
@@ -0,0 +1,11 @@
1
+ <%% content_tag_for :div, <%= singular_name %> do %>
2
+ <p>
3
+ <% for attribute in attributes %>
4
+ <strong><%= attribute.column.human_name %>:</strong> <%%=h <%= singular_name %>.<%= attribute.name %> %><br />
5
+ <% end %>
6
+ <%%= link_to 'Show', <%= singular_name %> %>
7
+ <%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %>
8
+ <%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %>
9
+
10
+ </p>
11
+ <%% end %>
@@ -0,0 +1,100 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+
3
+ before_filter :find_<%= file_name %>
4
+ before_filter :check_permissions_on_create_and_new, :only => [:create, :new]
5
+ before_filter :check_permissions_on_destroy, :only => :destroy
6
+ before_filter :check_permissions_on_edit_and_update, :only => [:edit, :update]
7
+ before_filter :check_permissions_on_index, :only => :index
8
+ before_filter :check_permissions_on_show, :only => :show
9
+
10
+ <%= file_name.pluralize.upcase %>_PER_PAGE = 20
11
+
12
+ def create
13
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
14
+ respond_to do |format|
15
+ if @<%= file_name %>.save
16
+ flash[:notice] = '<%= class_name %> was successfully created.'
17
+ format.html { redirect_to @<%= file_name %> }
18
+ format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
19
+ else
20
+ format.html { render :action => "new" }
21
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
22
+ end
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ respond_to do |format|
28
+ if @<%= file_name %>.destroy
29
+ flash[:notice] = '<%= class_name %> was successfully destroyed.'
30
+ format.html { redirect_to <%= file_name.pluralize %>_path }
31
+ format.xml { head :ok }
32
+ else
33
+ flash[:error] = '<%= class_name %> could not be destroyed.'
34
+ format.html { redirect_to @<%= file_name %> }
35
+ format.xml { head :unprocessable_entity }
36
+ end
37
+ end
38
+ end
39
+
40
+ def index
41
+ @<%= table_name %> = <%= class_name %>.paginate(:page => params[:page], :per_page => <%= file_name.pluralize.upcase %>_PER_PAGE)
42
+ respond_to do |format|
43
+ format.html
44
+ format.xml { render :xml => @<%= table_name %> }
45
+ end
46
+ end
47
+
48
+ def edit
49
+ end
50
+
51
+ def new
52
+ @<%= file_name %> = <%= class_name %>.new
53
+ respond_to do |format|
54
+ format.html
55
+ format.xml { render :xml => @<%= file_name %> }
56
+ end
57
+ end
58
+
59
+ def show
60
+ respond_to do |format|
61
+ format.html
62
+ format.xml { render :xml => @<%= file_name %> }
63
+ end
64
+ end
65
+
66
+ def update
67
+ respond_to do |format|
68
+ if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
69
+ flash[:notice] = '<%= class_name %> was successfully updated.'
70
+ format.html { redirect_to @<%= file_name %> }
71
+ format.xml { head :ok }
72
+ else
73
+ format.html { render :action => "edit" }
74
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
75
+ end
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def check_permissions_on_create_and_new
82
+ end
83
+
84
+ def check_permissions_on_destroy
85
+ end
86
+
87
+ def check_permissions_on_edit_and_update
88
+ end
89
+
90
+ def check_permissions_on_index
91
+ end
92
+
93
+ def check_permissions_on_show
94
+ end
95
+
96
+ def find_<%= file_name %>
97
+ @<%= file_name %> = <%= class_name %>.find(params[:id]) if params[:id]
98
+ end
99
+
100
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+
5
+ def test_create
6
+ <%= class_name %>.any_instance.expects(:save).returns(true)
7
+ post :create, :<%= file_name %> => { }
8
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
9
+ end
10
+
11
+ def test_create_with_failure
12
+ <%= class_name %>.any_instance.expects(:save).returns(false)
13
+ post :create, :<%= file_name %> => { }
14
+ assert_template "new"
15
+ end
16
+
17
+ def test_destroy
18
+ <%= class_name %>.any_instance.expects(:destroy).returns(true)
19
+ delete :destroy, :id => <%= table_name %>(:one).to_param
20
+ assert_not_nil flash[:notice]
21
+ assert_redirected_to <%= table_name %>_path
22
+ end
23
+
24
+ def test_destroy_with_failure
25
+ <%= class_name %>.any_instance.expects(:destroy).returns(false)
26
+ delete :destroy, :id => <%= table_name %>(:one).to_param
27
+ assert_not_nil flash[:error]
28
+ assert_redirected_to :action => "show"
29
+ end
30
+
31
+ def test_edit
32
+ get :edit, :id => <%= table_name %>(:one).to_param
33
+ assert_response :success
34
+ end
35
+
36
+ def test_index
37
+ get :index
38
+ assert_response :success
39
+ assert_not_nil assigns(:<%= table_name %>)
40
+ end
41
+
42
+ def test_new
43
+ get :new
44
+ assert_response :success
45
+ end
46
+
47
+ def test_show
48
+ get :show, :id => <%= table_name %>(:one).to_param
49
+ assert_response :success
50
+ end
51
+
52
+ def test_update
53
+ <%= class_name %>.any_instance.expects(:save).returns(true)
54
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
55
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
56
+ end
57
+
58
+ def test_update_with_failure
59
+ <%= class_name %>.any_instance.expects(:save).returns(false)
60
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
61
+ assert_template "edit"
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
@@ -0,0 +1,8 @@
1
+ <h2>Editing <%= singular_name %></h2>
2
+
3
+ <%%= render :partial => "form", :locals => {:<%= singular_name %> => @<%= singular_name %>} %>
4
+
5
+ <ul>
6
+ <li><%%= link_to 'Show', @<%= singular_name %> %></li>
7
+ <li><%%= link_to 'Back', <%= plural_name %>_path %></li>
8
+ </ul>
@@ -0,0 +1,14 @@
1
+ <h2>Listing <%= plural_name %></h2>
2
+
3
+ <%% if !@<%= plural_name %>.empty? %>
4
+ <div class="<%= plural_name %> clearfix">
5
+ <%%= render :partial => "<%= singular_name %>", :collection => @<%= plural_name %> %>
6
+ </div>
7
+ <%%= will_paginate(@<%= plural_name %>) %>
8
+ <%% else %>
9
+ <p>
10
+ There are no <%= plural_name %> to show yet.
11
+ </p>
12
+ <%% end %>
13
+
14
+ <%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
@@ -0,0 +1,7 @@
1
+ <h2>New <%= singular_name %></h2>
2
+
3
+ <%%= render :partial => "form", :locals => {:<%= singular_name %> => @<%= singular_name %>} %>
4
+
5
+ <ul>
6
+ <li><%%= link_to 'Back', <%= plural_name %>_path %></li>
7
+ </ul>
@@ -0,0 +1,13 @@
1
+ <h2><%= class_name %> "<%%= @<%= singular_name %>.to_param %>"</h2>
2
+
3
+ <%% content_tag_for :div, @<%= singular_name %> do %>
4
+ <% for attribute in attributes %>
5
+ <strong><%= attribute.column.human_name %>:</strong> <%%=h @<%= singular_name %>.<%= attribute.name %> %><br />
6
+ <% end %>
7
+ <%% end %>
8
+
9
+
10
+ <ul>
11
+ <li><%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %></li>
12
+ <li><%%= link_to 'Back', <%= plural_name %>_path %></li>
13
+ </ul>
data/init.rb ADDED
File without changes
@@ -0,0 +1,100 @@
1
+ class PostsController < ApplicationController
2
+
3
+ before_filter :find_post
4
+ before_filter :check_permissions_on_create_and_new, :only => [:create, :new]
5
+ before_filter :check_permissions_on_destroy, :only => :destroy
6
+ before_filter :check_permissions_on_edit_and_update, :only => [:edit, :update]
7
+ before_filter :check_permissions_on_index, :only => :index
8
+ before_filter :check_permissions_on_show, :only => :show
9
+
10
+ POSTS_PER_PAGE = 20
11
+
12
+ def create
13
+ @post = Post.new(params[:post])
14
+ respond_to do |format|
15
+ if @post.save
16
+ flash[:notice] = 'Post was successfully created.'
17
+ format.html { redirect_to @post }
18
+ format.xml { render :xml => @post, :status => :created, :location => @post }
19
+ else
20
+ format.html { render :action => "new" }
21
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
22
+ end
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ respond_to do |format|
28
+ if @post.destroy
29
+ flash[:notice] = 'Post was successfully destroyed.'
30
+ format.html { redirect_to posts_path }
31
+ format.xml { head :ok }
32
+ else
33
+ flash[:error] = 'Post could not be destroyed.'
34
+ format.html { redirect_to @post }
35
+ format.xml { head :unprocessable_entity }
36
+ end
37
+ end
38
+ end
39
+
40
+ def index
41
+ @posts = Post.paginate(:page => params[:page], :per_page => POSTS_PER_PAGE)
42
+ respond_to do |format|
43
+ format.html
44
+ format.xml { render :xml => @posts }
45
+ end
46
+ end
47
+
48
+ def edit
49
+ end
50
+
51
+ def new
52
+ @post = Post.new
53
+ respond_to do |format|
54
+ format.html
55
+ format.xml { render :xml => @post }
56
+ end
57
+ end
58
+
59
+ def show
60
+ respond_to do |format|
61
+ format.html
62
+ format.xml { render :xml => @post }
63
+ end
64
+ end
65
+
66
+ def update
67
+ respond_to do |format|
68
+ if @post.update_attributes(params[:post])
69
+ flash[:notice] = 'Post was successfully updated.'
70
+ format.html { redirect_to @post }
71
+ format.xml { head :ok }
72
+ else
73
+ format.html { render :action => "edit" }
74
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
75
+ end
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def check_permissions_on_create_and_new
82
+ end
83
+
84
+ def check_permissions_on_destroy
85
+ end
86
+
87
+ def check_permissions_on_edit_and_update
88
+ end
89
+
90
+ def check_permissions_on_index
91
+ end
92
+
93
+ def check_permissions_on_show
94
+ end
95
+
96
+ def find_post
97
+ @post = Post.find(params[:id]) if params[:id]
98
+ end
99
+
100
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ class PostsControllerTest < ActionController::TestCase
4
+
5
+ def test_create
6
+ Post.any_instance.expects(:save).returns(true)
7
+ post :create, :post => { }
8
+ assert_redirected_to post_path(assigns(:post))
9
+ end
10
+
11
+ def test_create_with_failure
12
+ Post.any_instance.expects(:save).returns(false)
13
+ post :create, :post => { }
14
+ assert_template "new"
15
+ end
16
+
17
+ def test_destroy
18
+ Post.any_instance.expects(:destroy).returns(true)
19
+ delete :destroy, :id => posts(:one).to_param
20
+ assert_not_nil flash[:notice]
21
+ assert_redirected_to posts_path
22
+ end
23
+
24
+ def test_destroy_with_failure
25
+ Post.any_instance.expects(:destroy).returns(false)
26
+ delete :destroy, :id => posts(:one).to_param
27
+ assert_not_nil flash[:error]
28
+ assert_redirected_to :action => "show"
29
+ end
30
+
31
+ def test_edit
32
+ get :edit, :id => posts(:one).to_param
33
+ assert_response :success
34
+ end
35
+
36
+ def test_index
37
+ get :index
38
+ assert_response :success
39
+ assert_not_nil assigns(:posts)
40
+ end
41
+
42
+ def test_new
43
+ get :new
44
+ assert_response :success
45
+ end
46
+
47
+ def test_show
48
+ get :show, :id => posts(:one).to_param
49
+ assert_response :success
50
+ end
51
+
52
+ def test_update
53
+ Post.any_instance.expects(:save).returns(true)
54
+ put :update, :id => posts(:one).to_param, :post => { }
55
+ assert_redirected_to post_path(assigns(:post))
56
+ end
57
+
58
+ def test_update_with_failure
59
+ Post.any_instance.expects(:save).returns(false)
60
+ put :update, :id => posts(:one).to_param, :post => { }
61
+ assert_template "edit"
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,19 @@
1
+ <% form_for(post) do |f| %>
2
+
3
+ <%= f.error_messages %>
4
+
5
+ <p>
6
+ <%= f.label :title %><br />
7
+ <%= f.text_field :title %>
8
+ </p>
9
+
10
+ <p>
11
+ <%= f.label :body %><br />
12
+ <%= f.text_area :body %>
13
+ </p>
14
+
15
+ <p>
16
+ <%= f.submit "Submit" %>
17
+ </p>
18
+
19
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <% content_tag_for :div, post do %>
2
+ <p>
3
+
4
+ <strong>Title:</strong> <%=h post.title %><br />
5
+
6
+ <strong>Body:</strong> <%=h post.body %><br />
7
+
8
+ <%= link_to 'Show', post %>
9
+ <%= link_to 'Edit', edit_post_path(post) %>
10
+ <%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %>
11
+
12
+ </p>
13
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <h2>Editing post</h2>
2
+
3
+ <%= render :partial => "form", :locals => {:post => @post} %>
4
+
5
+ <ul>
6
+ <li><%= link_to 'Show', @post %></li>
7
+ <li><%= link_to 'Back', posts_path %></li>
8
+ </ul>
@@ -0,0 +1,14 @@
1
+ <h2>Listing posts</h2>
2
+
3
+ <% if !@posts.empty? %>
4
+ <div class="posts clearfix">
5
+ <%= render :partial => "post", :collection => @posts %>
6
+ </div>
7
+ <%= will_paginate(@posts) %>
8
+ <% else %>
9
+ <p>
10
+ There are no posts to show yet.
11
+ </p>
12
+ <% end %>
13
+
14
+ <%= link_to 'New post', new_post_path %>
@@ -0,0 +1,7 @@
1
+ <h2>New post</h2>
2
+
3
+ <%= render :partial => "form", :locals => {:post => @post} %>
4
+
5
+ <ul>
6
+ <li><%= link_to 'Back', posts_path %></li>
7
+ </ul>
@@ -0,0 +1,15 @@
1
+ <h2>Post "<%= @post.to_param %>"</h2>
2
+
3
+ <% content_tag_for :div, @post do %>
4
+
5
+ <strong>Title:</strong> <%=h @post.title %><br />
6
+
7
+ <strong>Body:</strong> <%=h @post.body %><br />
8
+
9
+ <% end %>
10
+
11
+
12
+ <ul>
13
+ <li><%= link_to 'Edit', edit_post_path(@post) %></li>
14
+ <li><%= link_to 'Back', posts_path %></li>
15
+ </ul>
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: norman-randomba_scaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Norman Clarke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: will_paginate
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.2.2
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: mocha
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.9.0
32
+ version:
33
+ description: An improved Rails scaffold.
34
+ email: norman@randomba.org
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - MIT-LICENSE
43
+ - README.textile
44
+ - init.rb
45
+ - generators/randomba_scaffold/randomba_scaffold_generator.rb
46
+ - generators/randomba_scaffold/templates/_form.html.erb
47
+ - generators/randomba_scaffold/templates/_object.html.erb
48
+ - generators/randomba_scaffold/templates/controller.rb
49
+ - generators/randomba_scaffold/templates/functional_test.rb
50
+ - generators/randomba_scaffold/templates/helper.rb
51
+ - generators/randomba_scaffold/templates/view_edit.html.erb
52
+ - generators/randomba_scaffold/templates/view_index.html.erb
53
+ - generators/randomba_scaffold/templates/view_new.html.erb
54
+ - generators/randomba_scaffold/templates/view_show.html.erb
55
+ - samples/posts_controller.rb
56
+ - samples/posts_controller_test.rb
57
+ - samples/views/_form.html.erb
58
+ - samples/views/_post.html.erb
59
+ - samples/views/edit.html.erb
60
+ - samples/views/index.html.erb
61
+ - samples/views/new.html.erb
62
+ - samples/views/show.html.erb
63
+ has_rdoc: false
64
+ homepage: http://randomba.org
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.2.0
86
+ signing_key:
87
+ specification_version: 2
88
+ summary: An improved Rails scaffold.
89
+ test_files: []
90
+