advanced_scaffold 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +2 -0
  4. data/advanced_scaffold.gemspec +23 -0
  5. data/lib/advanced_scaffold.rb +10 -0
  6. data/lib/advanced_scaffold/helpers/sortable.rb +19 -0
  7. data/lib/advanced_scaffold/keep_params_in_session/.keep_params_in_session.rb.swp +0 -0
  8. data/lib/advanced_scaffold/keep_params_in_session/keep_params_in_session.rb +28 -0
  9. data/lib/advanced_scaffold/version.rb +3 -0
  10. data/lib/generators/advanced_scaffold/USAGE +7 -0
  11. data/lib/generators/advanced_scaffold/advanced_scaffold_generator.rb +273 -0
  12. data/lib/generators/advanced_scaffold/templates/.model.rb.swp +0 -0
  13. data/lib/generators/advanced_scaffold/templates/actions/create.rb +8 -0
  14. data/lib/generators/advanced_scaffold/templates/actions/destroy.rb +5 -0
  15. data/lib/generators/advanced_scaffold/templates/actions/edit.rb +3 -0
  16. data/lib/generators/advanced_scaffold/templates/actions/index.rb +10 -0
  17. data/lib/generators/advanced_scaffold/templates/actions/new.rb +3 -0
  18. data/lib/generators/advanced_scaffold/templates/actions/show.rb +3 -0
  19. data/lib/generators/advanced_scaffold/templates/actions/update.rb +8 -0
  20. data/lib/generators/advanced_scaffold/templates/advanced_scaffold.js +5 -0
  21. data/lib/generators/advanced_scaffold/templates/controller.rb +13 -0
  22. data/lib/generators/advanced_scaffold/templates/css/.advanced_scaffold.css.swp +0 -0
  23. data/lib/generators/advanced_scaffold/templates/css/advanced_scaffold.css +27 -0
  24. data/lib/generators/advanced_scaffold/templates/helper.rb +4 -0
  25. data/lib/generators/advanced_scaffold/templates/images/down_arrow.gif +0 -0
  26. data/lib/generators/advanced_scaffold/templates/images/up_arrow.gif +0 -0
  27. data/lib/generators/advanced_scaffold/templates/migration.rb +13 -0
  28. data/lib/generators/advanced_scaffold/templates/model.rb +20 -0
  29. data/lib/generators/advanced_scaffold/templates/views/_form.html.erb +14 -0
  30. data/lib/generators/advanced_scaffold/templates/views/_index.html.erb +29 -0
  31. data/lib/generators/advanced_scaffold/templates/views/_search.html.erb +14 -0
  32. data/lib/generators/advanced_scaffold/templates/views/edit.html.erb +14 -0
  33. data/lib/generators/advanced_scaffold/templates/views/index.html.erb +3 -0
  34. data/lib/generators/advanced_scaffold/templates/views/index.js.erb +1 -0
  35. data/lib/generators/advanced_scaffold/templates/views/new.html.erb +5 -0
  36. data/lib/generators/advanced_scaffold/templates/views/show.html.erb +20 -0
  37. metadata +133 -0
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in advanced_scaffold.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "advanced_scaffold/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "advanced_scaffold"
7
+ s.version = AdvancedScaffold::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Dmitry Biryukov"]
10
+ s.email = ["dmitry@biryukov.net"]
11
+ s.homepage = "https://github.com/dmitryz/advanced_scaffold"
12
+ s.summary = %q{Advanced scaffolding with pagination and ajax}
13
+ s.description = %q{Advanced scaffolding with pagination, ajax, search, namespaces}
14
+
15
+ s.rubyforge_project = "advanced_scaffold"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
21
+ s.add_runtime_dependency('dynamic_form')
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,10 @@
1
+ module AdvancedScaffold
2
+ # Your code goes here...
3
+ module Rails
4
+ class Railtie < ::Rails::Railtie
5
+ config.before_initialize do
6
+ config.action_view.javascript_expansions[:defaults] += %w(advanced_scaffold)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module Sortable
2
+ def sortable(column, title=nil)
3
+ title ||= column.titleize
4
+ css_class = column == sort_column ? "current #{sort_direction}" : nil
5
+ direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
6
+ link_to title, params.merge(:sort => column, :direction => direction, :page => nil),
7
+ {:class => css_class, :remote => true}
8
+ end
9
+ def title(page_title, show_title = true)
10
+ content_for(:title) { page_title.to_s }
11
+ @show_title = show_title
12
+ end
13
+ def show_title?
14
+ @show_title
15
+ end
16
+ def show_change_password?(o)
17
+ %{edit update}.include?(controller.action_name) && o.password.blank? && o.password_confirmation.blank?
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ module KeepParamsInSession
2
+ def save_last_path
3
+ session[:last_path] = request.env['PATH_INFO'].gsub("index", "")
4
+ end
5
+
6
+ def get_last_path
7
+ session[:last_path]
8
+ end
9
+
10
+
11
+ def keep_params_in_session(label, *keys)
12
+ sess_id_local = request.env['PATH_INFO'].gsub('/index', '')+'_'+label;
13
+ sess_id_global = 'global_'+label;
14
+ keys.each do |key|
15
+ if ((key.is_a? Hash) && key[:global])
16
+ key=key[:global]
17
+ sess_id=sess_id_global
18
+ elsif ((key.is_a? Hash) && key[:key] && key[:depend])
19
+ sess_id=sess_id_global+'_'+params[key[:depend]].to_s
20
+ key=key[:key]
21
+ else
22
+ sess_id=sess_id_local
23
+ end
24
+ params[key] = session["#{sess_id}#{key}"] if (params[key].nil? && !session["#{sess_id}#{key}"].nil?)
25
+ session["#{sess_id}#{key}"] = params[key] unless params[key].nil?
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module AdvancedScaffold
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ Description:
2
+ Advanced scaffold generator, creating scaffold with will_paginate, sortable columns, and search function.
3
+
4
+ Example:
5
+ rails generate advanced_scaffold ModelName model_attributes_array controller_actions
6
+
7
+ This will create:
@@ -0,0 +1,273 @@
1
+ require 'rails/generators/migration'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ module AdvancedScaffoldGenerator
5
+ module Generators
6
+ class AdvancedScaffoldGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ namespace "advanced_scaffold"
9
+ attr_accessor :scaffold_name, :model_attributes, :controller_actions
10
+
11
+ source_root File.expand_path('../templates', __FILE__)
12
+
13
+
14
+ argument :advanced_scaffold_name, :type => :string, :required => true, :banner => 'ModelName'
15
+ argument :args_for_c_m, :type => :array, :default => [], :banner => 'controller_actions and model:attributes'
16
+
17
+ class_option :skip_model, :desc => 'Don\'t generate a model or migration file.', :type => :boolean
18
+ class_option :skip_migration, :desc => 'Don\'t generate migration file for model.', :type => :boolean
19
+ class_option :skip_controller, :desc => 'Don\'t generate controller, helper, or views', :type => :boolean
20
+ class_option :controller_name, :desc => 'Set controller name', :type => :string
21
+ class_option :master_name, :desc => 'Set controller name < inheritance', :type => :string
22
+
23
+ def initialize(*args, &block)
24
+ super
25
+ # print_usage unless advanced_scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/
26
+ puts "advanced_scaffold_name=#{advanced_scaffold_name}"
27
+
28
+ @controller_actions = []
29
+ @model_attributes = []
30
+ @skip_model = options.skip_model?
31
+
32
+ args_for_c_m.each do |arg|
33
+ if arg.include?(':')
34
+ puts "model: #{arg}"
35
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
36
+ else
37
+ puts "controller: #{arg}"
38
+ @controller_actions << arg
39
+ end
40
+ end
41
+
42
+ @controller_actions.uniq!
43
+ @model_attributes.uniq!
44
+
45
+ @controller_actions = all_actions if @controller_actions.empty?
46
+
47
+ @skip_model = true if @model_attributes.empty?
48
+ end
49
+
50
+ def copy_js
51
+ copy_file("advanced_scaffold.js", "public/javascripts/advanced_scaffold.js")
52
+ end
53
+ def copy_css
54
+ copy_file("css/advanced_scaffold.css", "public/stylesheets/advanced_scaffold.css")
55
+ end
56
+ def copy_images
57
+ copy_file("images/down_arrow.gif", "public/images/advanced_scaffold/down_arrow.gif")
58
+ copy_file("images/up_arrow.gif", "public/images/advanced_scaffold/up_arrow.gif")
59
+ end
60
+ # def add_config
61
+ # inject_into_file "config/application.rb", :after => "config.action_view.javascript_expansions" do
62
+ # "config.action_view.javascript_expansions[:defaults] << %w(advanced_scaffold)"
63
+ # end
64
+ def create_model
65
+ template 'model.rb', "app/models/#{model_path}.rb" unless @skip_model
66
+ end
67
+
68
+ def create_migration
69
+ unless @skip_model || options.skip_migration?
70
+ migration_template 'migration.rb', "db/migrate/create_#{model_path.pluralize.gsub('/', '_')}.rb"
71
+ end
72
+ end
73
+
74
+ def create_controller
75
+ unless options.skip_controller?
76
+ template 'controller.rb', "app/controllers/#{plural_controller_name}_controller.rb"
77
+ template 'helper.rb', "app/helpers/#{plural_controller_name}_helper.rb"
78
+ controller_actions.each do |action|
79
+ if %w[index show new edit].include?(action)
80
+ template "views/#{action}.html.erb", "app/views/#{plural_controller_name}/#{action}.html.erb"
81
+ end
82
+ end
83
+
84
+ if form_partial?
85
+ template "views/_form.html.erb", "app/views/#{plural_controller_name}/_form.html.erb"
86
+ end
87
+ if index_partial?
88
+ template "views/_index.html.erb", "app/views/#{plural_controller_name}/_index.html.erb"
89
+ template "views/_search.html.erb", "app/views/#{plural_controller_name}/_search.html.erb"
90
+ end
91
+ if index_js?
92
+ template "views/index.js.erb", "app/views/#{plural_controller_name}/index.js.erb"
93
+ end
94
+ namespaces = plural_controller_name.split('/')
95
+ resource = namespaces.pop
96
+ route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
97
+ "namespace(:#{namespace}){ #{acc} }"
98
+ }
99
+ end
100
+ end
101
+
102
+ private
103
+
104
+ def form_partial?
105
+ actions? :new, :edit
106
+ end
107
+
108
+ def index_partial?
109
+ actions? :index
110
+ end
111
+
112
+ def index_js?
113
+ actions? :index
114
+ end
115
+
116
+
117
+ def action?(name)
118
+ controller_actions.include? name.to_s
119
+ end
120
+
121
+ def actions?(*names)
122
+ names.all? { |name| action? name }
123
+ end
124
+
125
+ def class_name
126
+ advanced_scaffold_name.split('::').last.camelize
127
+ end
128
+
129
+ def plural_class_name
130
+ plural_name.camelize
131
+ end
132
+
133
+ def camelize_master_name
134
+ master_name.camelize
135
+ end
136
+
137
+
138
+ def plural_controller_name
139
+ controller_name.camelize
140
+ end
141
+
142
+ def model_path
143
+ class_name.underscore
144
+ end
145
+
146
+ def all_actions
147
+ %w[index show new create edit update destroy]
148
+ end
149
+
150
+ def plural_name
151
+ advanced_scaffold_name.underscore.pluralize
152
+ end
153
+
154
+ def controller_name
155
+ options.controller_name.present? ? options.controller_name.underscore : singular_name
156
+ end
157
+
158
+ def camelize_controller_name
159
+ controller_name.camelize
160
+ end
161
+
162
+ def plural_controller_name
163
+ controller_name.underscore.pluralize
164
+ end
165
+
166
+ def plural_camelize_controller_name
167
+ plural_controller_name.camelize
168
+ end
169
+
170
+
171
+ def master_name
172
+ options.master_name.present? ? options.master_name.underscore : 'application'
173
+ end
174
+
175
+ def singular_name
176
+ advanced_scaffold_name.underscore
177
+ end
178
+
179
+ def singular_controller_name
180
+ controller_name.underscore
181
+ end
182
+
183
+ def table_name
184
+ plural_name.split('/').last
185
+ end
186
+
187
+ def instance_name
188
+ singular_name.split('/').last
189
+ end
190
+
191
+ def controller_instance_name
192
+ controller_name.split('/').last
193
+ end
194
+
195
+
196
+ def namespace_controller
197
+ controller_name.include?('/') ? controller_name.split('/').first : ""
198
+ end
199
+
200
+ def namespace_part_controller
201
+ controller_name.include?('/') ? controller_name.split('/').first+"_" : ""
202
+ end
203
+
204
+
205
+ def namespace
206
+ singular_name.include?('/') ? singular_name.split('/').first : ""
207
+ end
208
+ def namespace_part
209
+ singular_name.include?('/') ? singular_name.split('/').first+"_" : ""
210
+ end
211
+
212
+ def instances_url
213
+ namespace_part + instances_name + "_url"
214
+ end
215
+
216
+ def instances_path
217
+ namespace_part + instances_name + "_path"
218
+ end
219
+
220
+ def instance_path
221
+ namespace_part + instance_name + "_path"
222
+ end
223
+
224
+ def controller_instance_path
225
+ namespace_part_controller + controller_instance_name + "_path"
226
+ end
227
+
228
+ def controller_instances_path
229
+ namespace_part_controller + controller_instances_name + "_path"
230
+ end
231
+ def controller_instances_url
232
+ namespace_part_controller + controller_instances_name + "_url"
233
+ end
234
+
235
+
236
+
237
+
238
+
239
+ def instances_name
240
+ instance_name.pluralize
241
+ end
242
+
243
+ def controller_instances_name
244
+ controller_instance_name.pluralize
245
+ end
246
+
247
+
248
+
249
+ def print_usage
250
+ self.class.help(Thor::Base.shell.new)
251
+ exit
252
+ end
253
+
254
+ def controller_methods(dirname)
255
+ controller_actions.map do |action|
256
+ read_template("#{dirname}/#{action}.rb")
257
+ end.join("\n").strip
258
+ end
259
+
260
+ def read_template(relative_path)
261
+ ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
262
+ end
263
+
264
+ def self.next_migration_number(dirname)
265
+ if ActiveRecord::Base.timestamped_migrations
266
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
267
+ else
268
+ "%.3d" % (current_migration_number(dirname) + 1)
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
@@ -0,0 +1,8 @@
1
+ def create
2
+ @<%= instance_name %> = <%= class_name %>.new(params[:<%= instance_name %>])
3
+ if @<%= instance_name %>.save
4
+ redirect_to(<%= controller_instances_url %>, :notice => '<%= class_name %> was successfully created.')
5
+ else
6
+ render :action => "new"
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ def destroy
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ @<%= instance_name %>.destroy
4
+ redirect_to(<%= controller_instances_url %>, :notice => 'Successfully deleted')
5
+ end
@@ -0,0 +1,3 @@
1
+ def edit
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ end
@@ -0,0 +1,10 @@
1
+ def index
2
+ save_last_path
3
+ params[:search] = "" if params[:remove_filter]
4
+ keep_params_in_session('<%= instances_name %>_index', { :global => :page },
5
+ { :glboal => :direction},
6
+ { :global => :sort},
7
+ { :global => :search})
8
+
9
+ @<%= instances_name %> = <%= class_name %>.search(params[:search]).order(sort_column + " " + sort_direction).pag(params[:page])
10
+ end
@@ -0,0 +1,3 @@
1
+ def new
2
+ @<%= instance_name %> = <%= class_name %>.new
3
+ end
@@ -0,0 +1,3 @@
1
+ def show
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ end
@@ -0,0 +1,8 @@
1
+ def update
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
+ redirect_to(<%= controller_instances_url %>, :notice => "<%= class_name %> #{@<%= instance_name %>.id} was successfully updated.")
5
+ else
6
+ render :action => "edit"
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ $('.pagination a').live('click',function (){
2
+ $.getScript(this.href);
3
+ return false;
4
+ });
5
+
@@ -0,0 +1,13 @@
1
+ class <%= plural_camelize_controller_name %>Controller < <%= camelize_master_name %>Controller
2
+ require 'advanced_scaffold/keep_params_in_session/keep_params_in_session'
3
+ include KeepParamsInSession
4
+ helper_method :sort_column, :sort_direction
5
+ <%= controller_methods :actions %>
6
+ private
7
+ def sort_column
8
+ <%= class_name %>.column_names.include?(params[:sort]) ? params[:sort] : "<%= model_attributes.first.name %>"
9
+ end
10
+ def sort_direction
11
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ table.pretty {
2
+ border-collapse: collapse;
3
+ margin-bottom: 10px;
4
+ }
5
+
6
+ .pretty td, .pretty th {
7
+ padding: 4px 10px;
8
+ border: solid 1px #AAA;
9
+ }
10
+
11
+ .pretty .price {
12
+ text-align: right;
13
+ }
14
+
15
+ .pretty th .current {
16
+ padding-right: 12px;
17
+ background-repeat: no-repeat;
18
+ background-position: right center;
19
+ }
20
+
21
+ .pretty th .asc {
22
+ background-image: url(/images/advanced_scaffold/up_arrow.gif);
23
+ }
24
+
25
+ .pretty th .desc {
26
+ background-image: url(/images/advanced_scaffold/down_arrow.gif);
27
+ }
@@ -0,0 +1,4 @@
1
+ module <%= plural_camelize_controller_name %>Helper
2
+ require 'advanced_scaffold/helpers/sortable'
3
+ include Sortable
4
+ end
@@ -0,0 +1,13 @@
1
+ class Create<%= class_name.pluralize.delete('::') %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :<%= table_name %> do |t|
4
+ <%- for attribute in model_attributes -%>
5
+ t.<%= attribute.type %> :<%= attribute.name %>
6
+ <%- end -%>
7
+ t.timestamps
8
+ end
9
+ end
10
+ def self.down
11
+ drop_table :<%= table_name %>
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ attr_accessible <%= model_attributes.map { |a| ":#{a.name}"}.join(", ") %>
3
+
4
+ def self.per_page
5
+ 15
6
+ end
7
+
8
+ def self.pag(page="", conditions="", per_page=nil)
9
+ paginate :per_page => per_page.present? ? per_page : self.per_page,
10
+ :page => !page.blank? ? page:nil,
11
+ :conditions => conditions
12
+ end
13
+ def self.search(search)
14
+ if search.present?
15
+ where('<%= model_attributes.map { |a| "#{a.name} RLIKE :search" if %w[string text].include?(a.type.to_s) }.compact.join(" or ") %>', :search => search)
16
+ else
17
+ scoped
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ <%%= form_for ([<%= namespace_controller.present? ? ":#{namespace_controller}, ":"" %>@<%= instance_name %>]) do |f| %>
2
+ <div id="error_explanation">
3
+ <%%= f.error_messages %>
4
+ </div>
5
+ <%- for attribute in model_attributes -%>
6
+ <div class="field">
7
+ <%%= f.label :<%=attribute.name %> %><br />
8
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
9
+ </div>
10
+ <%- end -%>
11
+ <div class="actions">
12
+ <%%= f.submit %>
13
+ </div>
14
+ <%% end %>
@@ -0,0 +1,29 @@
1
+ <div id="<%= instances_name %>_paginate">
2
+ <%%= will_paginate @<%=instances_name %>, :params => { :id => params[:id] } %><BR />
3
+ </div>
4
+ <%%= render :partial => 'search.html.erb' %>
5
+ <table id="t_<%= instance_name %>_index" class="pretty">
6
+ <tr>
7
+ <%- for attribute in model_attributes -%>
8
+ <th><%%= sortable "<%= attribute.name %>" %></th>
9
+ <%- end -%>
10
+ <th colspan=3>Actions</th>
11
+ </tr>
12
+ <%% @<%= instances_name %>.each do |t| %>
13
+ <tr>
14
+ <%- for attribute in model_attributes -%>
15
+ <td><%%= t.<%= attribute.name %> %></td>
16
+ <%- end -%>
17
+ <%- if action? :show -%>
18
+ <td><%%= link_to "Show", <%= controller_instance_path %>(t) %></td>
19
+ <%- end -%>
20
+ <%- if action? :edit -%>
21
+ <td><%%= link_to "Edit", edit_<%= controller_instance_path %>(t) %></td>
22
+ <%- end -%>
23
+ <%- if action? :destroy -%>
24
+ <td><%%= link_to "Destroy", <%= controller_instance_path %>(t), :confirm => 'Are you sure?', :method => :delete %></td>
25
+ <%- end -%>
26
+ </tr>
27
+ <%% end %>
28
+ </table><BR />
29
+ <%%= link_to 'New <%= instance_name %>', new_<%= controller_instance_path %> %>
@@ -0,0 +1,14 @@
1
+ <%% if params[:search].blank? %>
2
+ <div class="field" id="search_link">
3
+ <%%= link_to_function "Search", "$('div#search_link').hide(); $('div#search_field').show()" %>
4
+ </div>
5
+ <%% else %>
6
+ <%%= link_to "Remove filter", { :remove_filter => true }, :remote => true %>
7
+ <%% end %>
8
+ <div id="search_field" style="<%%= params[:search].blank? ? "display:none":"" %>">
9
+ <%%= form_tag '', :method => :get, :remote => true do %>
10
+ <%%= hidden_field_tag :page, 1 %>
11
+ Search: <%%= text_field_tag :search, params[:search] %>
12
+ <%%= submit_tag "Search", :name => "do_search" %>
13
+ <%% end %>
14
+ </div>
@@ -0,0 +1,14 @@
1
+ <%% title "Edit <%= singular_name.titleize %>" %>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%- if actions? :show, :index -%>
6
+ <p>
7
+ <%- if action? :show -%>
8
+ <%%= link_to "Show", <%= controller_instance_path %>(@<%= instance_name%>) %>
9
+ <%- end -%>
10
+ <%- if action? :index -%>
11
+ <%%= link_to "Back", <%= controller_instances_path %> %>
12
+ <%- end -%>
13
+ </p>
14
+ <%- end -%>
@@ -0,0 +1,3 @@
1
+ <div id="<%= instances_name+'_index_list' %>">
2
+ <%%= render :partial => 'index' %>
3
+ </div>
@@ -0,0 +1 @@
1
+ $("#<%= instances_name %>_index_list").html("<%%= escape_javascript( render( :partial => "index.html.erb")) %>");
@@ -0,0 +1,5 @@
1
+ <%% title "New <%= singular_name.titleize %>" %>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Back', <%= controller_instances_path %> %>
@@ -0,0 +1,20 @@
1
+ <%% title "<%= singular_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <strong><%= attribute.human_name.titleize %>:</strong>
6
+ <%%= @<%= instance_name %>.<%= attribute.name %> %>
7
+ </p>
8
+ <%- end -%>
9
+
10
+ <p>
11
+ <%- if action? :edit -%>
12
+ <%%= link_to "Edit", <%= "edit_"+controller_instance_path %>(@<%= instance_name %>) %> |
13
+ <%- end -%>
14
+ <%- if action? :destroy -%>
15
+ <%%= link_to "Destroy", <%= controller_instance_path %>(@<%= instance_name %>), :confirm => 'Are you sure?', :method => :delete %> |
16
+ <%- end -%>
17
+ <%- if action? :index -%>
18
+ <%%= link_to "Back", <%= controller_instances_path %> %>
19
+ <%- end -%>
20
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: advanced_scaffold
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dmitry Biryukov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-25 00:00:00 +03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: will_paginate
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 1923831917
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - pre
34
+ - 2
35
+ version: 3.0.pre2
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: dynamic_form
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ description: Advanced scaffolding with pagination, ajax, search, namespaces
53
+ email:
54
+ - dmitry@biryukov.net
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Rakefile
65
+ - advanced_scaffold.gemspec
66
+ - lib/advanced_scaffold.rb
67
+ - lib/advanced_scaffold/helpers/sortable.rb
68
+ - lib/advanced_scaffold/keep_params_in_session/.keep_params_in_session.rb.swp
69
+ - lib/advanced_scaffold/keep_params_in_session/keep_params_in_session.rb
70
+ - lib/advanced_scaffold/version.rb
71
+ - lib/generators/advanced_scaffold/USAGE
72
+ - lib/generators/advanced_scaffold/advanced_scaffold_generator.rb
73
+ - lib/generators/advanced_scaffold/templates/.model.rb.swp
74
+ - lib/generators/advanced_scaffold/templates/actions/create.rb
75
+ - lib/generators/advanced_scaffold/templates/actions/destroy.rb
76
+ - lib/generators/advanced_scaffold/templates/actions/edit.rb
77
+ - lib/generators/advanced_scaffold/templates/actions/index.rb
78
+ - lib/generators/advanced_scaffold/templates/actions/new.rb
79
+ - lib/generators/advanced_scaffold/templates/actions/show.rb
80
+ - lib/generators/advanced_scaffold/templates/actions/update.rb
81
+ - lib/generators/advanced_scaffold/templates/advanced_scaffold.js
82
+ - lib/generators/advanced_scaffold/templates/controller.rb
83
+ - lib/generators/advanced_scaffold/templates/css/.advanced_scaffold.css.swp
84
+ - lib/generators/advanced_scaffold/templates/css/advanced_scaffold.css
85
+ - lib/generators/advanced_scaffold/templates/helper.rb
86
+ - lib/generators/advanced_scaffold/templates/images/down_arrow.gif
87
+ - lib/generators/advanced_scaffold/templates/images/up_arrow.gif
88
+ - lib/generators/advanced_scaffold/templates/migration.rb
89
+ - lib/generators/advanced_scaffold/templates/model.rb
90
+ - lib/generators/advanced_scaffold/templates/views/_form.html.erb
91
+ - lib/generators/advanced_scaffold/templates/views/_index.html.erb
92
+ - lib/generators/advanced_scaffold/templates/views/_search.html.erb
93
+ - lib/generators/advanced_scaffold/templates/views/edit.html.erb
94
+ - lib/generators/advanced_scaffold/templates/views/index.html.erb
95
+ - lib/generators/advanced_scaffold/templates/views/index.js.erb
96
+ - lib/generators/advanced_scaffold/templates/views/new.html.erb
97
+ - lib/generators/advanced_scaffold/templates/views/show.html.erb
98
+ has_rdoc: true
99
+ homepage: https://github.com/dmitryz/advanced_scaffold
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ requirements: []
126
+
127
+ rubyforge_project: advanced_scaffold
128
+ rubygems_version: 1.5.2
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: Advanced scaffolding with pagination and ajax
132
+ test_files: []
133
+