Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactoring. Added support for additional arguments for actions…
… and respond_to-formats that is not supported by the Rails-scaffold.
- Loading branch information
Showing
23 changed files
with
393 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
h1. TODO | ||
|
||
h2. Most probably | ||
|
||
* Something like "model_generator_with_factories" (using machinist, factory_girl, ...). Source: http://github.com/vigetlabs/model_generator_with_factories/tree/master | ||
* Break up in different generators: dry_controller, dry_views, etc., and use as dependencies in dry_scaffold | ||
|
||
h2. Maybe | ||
|
||
* Check for overridden templates in: RAILS_ROOT/lib/dry_scaffold/templates/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 14 additions & 4 deletions
18
generators/dry_scaffold/templates/controller_inherited_resources.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
class <%= controller_class_name %>Controller < InheritedResources::Base | ||
actions :index, :show, :new, :create, :edit, :update, :destroy | ||
respond_to :html, :xml, :json | ||
<% if actions -%> | ||
actions <%= symbol_array_to_expression(actions) %> | ||
<% end -%> | ||
<% if formats -%> | ||
respond_to <%= symbol_array_to_expression(formats) %> | ||
<% end -%> | ||
<% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%> | ||
# GET /<%= plural_name %>/<%= action.to_s %> | ||
def <%= action.to_s %> | ||
end | ||
<% end -%> | ||
protected | ||
|
||
def collection | ||
paginate_options ||= {} | ||
paginate_options[:page] ||= (params[:page] || 1) | ||
paginate_options[:per_page] ||= (params[:per_page] || 20) | ||
@<%= plural_name %> ||= end_of_association_chain.paginate(paginate_options) | ||
@collection = @<%= plural_name %> ||= end_of_association_chain.paginate(paginate_options) | ||
end | ||
def resource | ||
@<%= singular_name %> ||= end_of_association_chain.find(params[:id]) | ||
@resource = @<%= singular_name %> ||= end_of_association_chain.find(params[:id]) | ||
end | ||
|
||
end |
Oops, something went wrong.