README.textile in grimen-dry_scaffold-0.2.3 vs README.textile in grimen-dry_scaffold-0.2.4
- old
+ new
@@ -1,37 +1,37 @@
h1. DRY SCAFFOLD
-A Rails scaffold generator that generates DRYer, cleaner, and more useful code.
+_A Rails scaffold generator that generates DRYer, cleaner, and more useful code._
h2. Description
DryScaffold is a replacement for the Rails scaffold generator that generates code that most people end up deleting or rewriting anyway because of the unusable code. The scaffold concept is powerful, but it has more potential than generating messy and almost useless code - something that might change with Rails 3 though. The goal with DryScaffold is to generate DRY, beautiful, and standards compliant code based on common patterns without adding a lot of assumptions.
-h3. Key Concepts:
-
+*Key Concepts:*
+
* Controllers that are DRY, RESTful, no code-smells, following conventions, and implementing VERY common patterns.
* Views that are DRY, semantic, standards compliant, valid, and more useful in development.
* Factories instead of fixtures.
* Generator that gets smart with additional arguments - but not stupid without them.
* Any Rails developer should be able to switch generator with no effort - follow current conventions, but extend them.
h2. Dependencies
h3. Required:
-
+
* "*haml*":http://github.com/nex3/haml - ERB sucks like PHP, end of story
h3. Optional:
-
+
h4. Controllers/Views
-
+
* "*will_paginate*":http://github.com/mislav/will_paginate - Pagination
* "*formtastic*":http://github.com/justinfrench/formtastic - DRY and semantic forms
* "*inherited_resources*":http://github.com/josevalim/inherited_resources - DRY/Resourceful controllers
-
+
h4. Models
-
+
* "*factory_girl*":http://github.com/thoughtbot/factory_girl - Fixture-replacement
* "*machinist*":http://github.com/notahat/machinist - Fixture-replacement
* "*object_daddy*":http://github.com/flogic/object_daddy - Fixture-replacement
h2. Features
@@ -51,12 +51,14 @@
h3. Formtastic Forms
Quick and dirty; Formtastic makes your form views cleaner, and your life as a Rails developer easier (for real). Formtastic forms can be turned off, but I would recommend any Rails developer to consider using it - there is really no good reason not to if you not running very old version of Rails.
-h4. Default HAML (without Formtastic):
+h4. Standard
+HAML + ActionView FormHelpers:
+
<pre>- form_for(@duck) do |f|
= f.error_messages
%ul
%li
= f.label :name, 'Name'
@@ -65,12 +67,14 @@
= f.label :about, 'About'
= f.text_area :about
%p.buttons
= f.submit 'Create'</pre>
-h4. Formtastic + HAML:
+h4. Formtastic
+HAML + Formtastic:
+
<pre>- semantic_form_for(@duck) do |f|
- f.inputs do
= f.input :name
= f.input :about
- f.buttons do
@@ -80,24 +84,28 @@
h3. Resourceful Controllers
Quick and dirty; InheritedResources makes your controllers controllers cleaner, and might make experienced Rails developer's life DRYer code wise. This is possible because of REST as a convention in Rails, and therefore the patterns that arise in controllers can be DRYed up A LOT. Resourceful - InheritedResources-based - controllers can be turned off, but I would recommend any experienced Rails developer to consider using it - there is really no good reason not to unless maybe if you are a Rails beginner, then you should consider get used to the basic Rails building blocks first.
-h4. Default (without InheritedResources)
+h4. Standard
+Using ActionController:
+
<pre>def new
@duck = Duck.new
respond_to do |format|
format.html # new.html.haml
format.xml { render :xml => @duck }
format.json { render :json => @duck }
end
end</pre>
-h4. Resourceful (InheritedResources)
+h4. Resourceful
+Using InheritedResources:
+
<pre>actions :new
respond_to :html, :xml, :json</pre>
Find out more about *inherited_resources*: "http://github.com/josevalim/inherited_resources":http://github.com/josevalim/inherited_resources
@@ -105,16 +113,18 @@
Pagination is such a common feature that always seems to be implemented anyway, so DryScaffold will generate a DRY solution for this in each controller that you can tweak - even thought that will not be needed in most cases. See DRY Patterns beneath for more details how it's done. Pagination - using WillPaginate - can be turned off.
Find out more about *will_paginate*: "http://github.com/mislav/will_paginate":http://github.com/mislav/will_paginate
-h3. DRY Patterns
+h3. DRYying Patterns
Either if you choosing default or resourceful controllers, this pattern is used to DRYing up controllers a bit more, and at the same time loading resources in the same place using before_filter while adding automatic pagination for collections.
-h4. Default (ActionController with pagination - not using InheritedResources)
+h4. Standard
+ActionController with pagination:
+
<pre>before_filter :load_resource, :only => [:show, :edit, :update, :destroy]
before_filter :load_and_paginate_resources, :only => [:index]
...
@@ -131,12 +141,14 @@
def resource
@resource = @resource = ||= Duck.find(params[:id])
end
alias :load_resource :resource</pre>
-h4. Resourceful (InheritedResources with pagination)
+h4. Resourceful
+InheritedResources with pagination:
+
<pre>protected
def collection
paginate_options ||= {}
paginate_options[:page] ||= (params[:page] || 1)
@@ -150,73 +162,68 @@
h3. View Partials
A very common pattern is to break up views in partials, which is also what DryScaffold does:
-* new/edit => _form
-* index => _item
+* @new@/@edit@ => @_form@
+* @index@ => @_item@
h3. More To Come... (TODO)
These are things I have in mind:
* Handle belongs_to, i.e. specify MODEL --belongs-to PARENT_MODEL, which generates proper routes, proper before-filters if inherited_resources-controller, adding belongs_to-association in model, and correct form_for arguments.
* Choose test suits: testunit/shoulda/rspec
h2. Setup
-Installing DryScaffold is easy as 1-2-3...nah, really:
+Installing DryScaffold is easy:
h3. 1. Installation
Install DryScaffold...
h4. Gem (Recommended)
-<pre>gem sources -a http://gems.github.com
-sudo gem install grimen-dry_scaffold</pre>
+<pre>sudo gem install grimen-dry_scaffold --source http://gems.github.com</pre>
+...and in config: @config/environments/development.rb@
+
+<pre>config.gem 'grimen-dry_scaffold', :lib => 'dry_scaffold', :source => 'http://gems.github.com'</pre>
+
h4. Plugin
<pre>./script/plugin install git://github.com/grimen/dry_scaffold.git</pre>
-h3. 2. Configuration (Gem only)
+h3. 2. Install Dependencies (Partly optional)
-In: @config/environments/development.rb@
-
-<pre>config.gem 'grimen-dry_scaffold', :lib => 'dry_scaffold'</pre>
-
-h3. 3. Install Dependencies (Partly optional)
-
Install dependencies to release the full power of dry_scaffold. Only HAML is really required of these, but how could anyone resist candy? =)
-h4. Express
+h4. Automatic/Express
For us lazy ones... =)
<pre>rake dry_scaffold:setup</pre>
Will install the dependencies, initialize HAML within current Rails project if not already done, and automatically referencing the dependency gems within the current Rails project environment config if they are not already in there (note: nothing will be overwritten).
-h4. Installation
+h4. Manual
-Get the gems...
+Get the gems...you want:
-<pre>sudo gem install haml</pre>
-<pre>sudo gem install will_paginate</pre>
-<pre>sudo gem install justinfrench-formtastic</pre>
-<pre>sudo gem install josevalim-inherited_resources</pre>
+<pre>sudo gem install haml
+sudo gem install will_paginate
+sudo gem install justinfrench-formtastic
+sudo gem install josevalim-inherited_resources</pre>
-h4. B2. Configuration
+...and same for the config config: @config/environments/development.rb@
-In: @config/environment.rb@
+<pre>config.gem 'haml'
+config.gem 'will_paginate'
+config.gem 'justinfrench-formtastic', :lib => 'formtastic, :source => 'http://gems.github.com'
+config.gem 'josevalim-inherited_resources', :lib => 'inherited_resources', :source => 'http://gems.github.com'</pre>
-<pre>config.gem 'haml'</pre>
-<pre>config.gem 'will_paginate'</pre>
-<pre>config.gem 'justinfrench-formtastic', :lib => 'formtastic, :source => 'http://gems.github.com'</pre>
-<pre>config.gem 'josevalim-inherited_resources', :lib => 'inherited_resources', :source => 'http://gems.github.com'</pre>
-
h2. Usage
<pre>./script/generate dry_scaffold ModelName [attribute:type attribute:type] [_actions:new,create,...] [_formats:html,json,...] [_indexes:attribute,...] [--skip-pagination] [--skip-resourceful] [--skip-formtastic] [--skip-views] [--skip-helpers] [--skip-tests] [--include-layout] [--fixtures] [--fgirl] [--machinist] [--odaddy] [--skip-migration] [--skip-timestamps]</pre>
...or use the alias @dscaffold@ instead of @dry_scaffold@.
@@ -362,22 +369,26 @@
Example:
<pre>--skip-resourceful --layout</pre>
-h4. General
+h4. Scaffold
+These are the options for the scaffold-generator.
+
* @--skip-pagination@ - Don't generate pagination of collections in controller and views, i.e. don't use *will_paginate*.
* @--skip-resourceful@ - Don't generate resourceful controller, i.e. don't use *inherited_resources*.
* @--skip-formtastic@ - Don't generate formtastic forms in views, i.e. don't use *formtastic*.
* @--skip-views@ - Don't generate views.
* @--skip-helpers@ - Don't generate helpers.
* @--skip-tests@ - Don't generate tests (functional/unit/...).
* @--skip-builders@ - Don't generate builders.
* @--layout@ - Generate layout.
+
+h4. Model
-h4. Model-specific
+These are the options for the model/scaffold-generators.
* @--fixtures@ - Generate fixtures.
* @--fgirl@ - Generate *factory_girl* factories.
* @--machinist@ - Generate *machinist* blueprints (factories).
* @--odaddy@ - Generate *object_daddy* generator/factory methods.
@@ -398,19 +409,21 @@
For your inspiration, you could try the following:
<pre>./script/generate dry_scaffold Zebra name:string about:text --skip-resourceful
./script/generate dry_scaffold Kangaroo name:string about:text --skip-formtastic
-./script/generate dry_scaffold Duck name:string about:text _actions:new,create,index,quack
-./script/generate dry_scaffold Parrot name:string about:text _formats:html,xml,yml
-./script/generate dry_scaffold GoldFish name:string about:text _indexes:name --fgirl
-./script/generate dry_scaffold Frog name:string about:text _indexes:name,name+about --fixtures</pre>
+./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
+./script/generate dscaffold Parrot name:string about:text _formats:html,xml,yml
+./script/generate dscaffold GoldFish name:string about:text _indexes:name --fgirl
+./script/generate dry_model Frog name:string about:text _indexes:name,name+about --fixtures</pre>
...or just go crazy!
h2. Bugs & Feedback
If you experience any issues/bugs or have feature requests, just file a GitHub-issue or send me a message.
If you think parts of my implementation could be implemented nicer somehow, please let me know...or just fork it and fix it yourself! =)
At last, positive feedback is always appreciated!
-Copyright (c) 2009 Jonas Grimfelt, released under MIT-license
+h2. License
+
+Copyright (c) 2009 Jonas Grimfelt, released under the MIT-license.
\ No newline at end of file