dry_crud 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +67 -33
- data/VERSION +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/add.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/delete.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/edit.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/list.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/show.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/stylesheets/crud.scss +12 -22
- data/{lib/generators/dry_crud/templates/app → app}/assets/stylesheets/sample.scss +157 -106
- data/{lib/generators/dry_crud/templates/app → app}/controllers/crud_controller.rb +15 -16
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/generic_model.rb +7 -7
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/nestable.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/rememberable.rb +3 -3
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/render_callbacks.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/responder.rb +2 -2
- data/app/controllers/dry_crud/searchable.rb +77 -0
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/sortable.rb +9 -7
- data/{lib/generators/dry_crud/templates/app → app}/controllers/list_controller.rb +11 -9
- data/{lib/generators/dry_crud/templates/app → app}/helpers/actions_helper.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb → app/helpers/dry_crud/form/builder.rb} +147 -164
- data/app/helpers/dry_crud/form/control.rb +180 -0
- data/app/helpers/dry_crud/table/actions.rb +88 -0
- data/app/helpers/dry_crud/table/builder.rb +115 -0
- data/app/helpers/dry_crud/table/col.rb +25 -0
- data/app/helpers/dry_crud/table/sorting.rb +61 -0
- data/{lib/generators/dry_crud/templates/app → app}/helpers/form_helper.rb +3 -2
- data/{lib/generators/dry_crud/templates/app → app}/helpers/format_helper.rb +5 -5
- data/{lib/generators/dry_crud/templates/app → app}/helpers/i18n_helper.rb +2 -2
- data/{lib/generators/dry_crud/templates/app → app}/helpers/table_helper.rb +8 -7
- data/{lib/generators/dry_crud/templates/app → app}/helpers/utility_helper.rb +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_edit.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_edit.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_show.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_show.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_attrs.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_attrs.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_form.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_form.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_list.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_list.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/edit.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/edit.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/new.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/new.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/show.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/show.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_flash.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_flash.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_nav.html.erb +2 -2
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_nav.html.haml +2 -2
- data/{lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb → app/views/layouts/application.html.erb} +22 -16
- data/{lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml → app/views/layouts/application.html.haml} +17 -11
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_actions_index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_actions_index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_list.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_list.html.haml +0 -0
- data/app/views/list/_search.html.erb +10 -0
- data/app/views/list/_search.html.haml +7 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_error_messages.html.erb +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_error_messages.html.haml +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_labeled.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_labeled.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/config → config}/locales/crud.de.yml +0 -0
- data/{lib/generators/dry_crud/templates/config → config}/locales/crud.en.yml +0 -0
- data/lib/dry_crud/engine.rb +18 -0
- data/lib/dry_crud.rb +5 -0
- data/lib/generators/dry_crud/dry_crud_generator.rb +12 -20
- data/lib/generators/dry_crud/dry_crud_generator_base.rb +57 -0
- data/lib/generators/dry_crud/file_generator.rb +41 -0
- data/lib/generators/dry_crud/templates/INSTALL +1 -1
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/helpers/{crud/form_builder_spec.rb → dry_crud/form/builder_spec.rb} +28 -19
- data/lib/generators/dry_crud/templates/spec/helpers/{crud/table_builder_spec.rb → dry_crud/table/builder_spec.rb} +3 -3
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +21 -40
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +36 -26
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +4 -4
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +6 -6
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +0 -1
- data/lib/generators/dry_crud/templates/test/helpers/{crud/form_builder_test.rb → dry_crud/form/builder_test.rb} +38 -25
- data/lib/generators/dry_crud/templates/test/helpers/{crud/table_builder_test.rb → dry_crud/table/builder_test.rb} +4 -4
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +12 -9
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +13 -1
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +4 -4
- data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +3 -3
- data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +2 -2
- metadata +76 -68
- data/lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb +0 -55
- data/lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb +0 -280
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +0 -6
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.haml +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmM5NzIxMmM5YTE2YzE5YTU1NWRkNDc5OTAxODkxOGU2NjE0NTA4Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjM3NzY0Y2VkMTllMWNmZTUwYjk1ZWRmZTgyOTgyMzA5NWFjOWU0Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWM1ZmVjY2JlZjg4NjNiMjU1NmNlYTk3NTdlZDQzMTk2NzMzNjY0NWRlMzBm
|
10
|
+
YzJmZTQ2OWNiMmNkMWZmNzllZWVmODA4NGE0Yzc4N2M5NGNmMWRhN2Y5N2U3
|
11
|
+
ODg4YTFmYzNmNjk0ZTUxYWZiM2ViZDllOGZjODI1NjE3OTYyYzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjU1YmUwYjVmYzdjZjg5OGZiYjE2ZmU2NGYzYTA0OTkwNTg4ZmEzM2NkY2M4
|
14
|
+
OWZkNzAzZGJhNzU3NmRjM2I2MDIyZWRlMGNiM2MwNWRhZTQ5NTMxMjEzMTRk
|
15
|
+
ZDUyYTZlZDc1NTk5ZWYyODRiNWUxN2RiMmU5NjJjZTg5MmE2NGE=
|
data/README.rdoc
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
{<img src="https://secure.travis-ci.org/codez/dry_crud.png" />}[http://travis-ci.org/codez/dry_crud]
|
4
4
|
|
5
|
-
dry_crud generates simple and extendable controllers, views and helpers that support you to DRY up the CRUD code in your Rails projects. Start with these artifacts and build a clean base to efficiently develop your application upon.
|
5
|
+
dry_crud generates simple and extendable controllers, views and helpers that support you to DRY up the CRUD code in your Rails projects. List, search, sort, show, create, edit and destroy any model entries in just 5 minutes. Start with these artifacts and build a clean base to efficiently develop your application upon.
|
6
|
+
|
7
|
+
|
8
|
+
== Installation
|
6
9
|
|
7
10
|
Create your Rails application directly with the dry_crud application template:
|
8
11
|
|
@@ -14,16 +17,28 @@ If your application already exists or you prefer the DIY way, then install the G
|
|
14
17
|
|
15
18
|
By default, dry_crud generates ERB templates and Test::Unit tests. Pass the options above to generate HAML templates and/or RSpec examples instead.
|
16
19
|
|
20
|
+
We recommend to use dry_crud as a generator as described above for the best understanding and the most flexibility. When you are familiar with dry_crud, it is now also possible to use it directly as a Rails Engine. Simply add the gem to your Gemfile. You may still generate single files to adapt them:
|
21
|
+
|
22
|
+
rails generate dry_crud:file list/index.html.erb
|
23
|
+
|
24
|
+
If a dry_crud file exists in your application, it will be used, if not, the one from the engine is used. This holds for controllers, helpers and view templates.
|
25
|
+
|
26
|
+
|
27
|
+
== Integration
|
28
|
+
|
17
29
|
To integrate dry_crud into your code, only a few additions are required:
|
18
30
|
|
19
|
-
* For uniform CRUD functionality, just subclass your controllers from CrudController.
|
31
|
+
* For uniform CRUD functionality, just subclass your controllers from CrudController and define the +permitted_attrs+ (for StrongParameters).
|
20
32
|
* Overwrite the +to_s+ method of your models for a human-friendly representation in captions.
|
33
|
+
* Optionally define a +list+ scope in your models to be used in the +index+ action.
|
34
|
+
* Optionally define a +options_list+ scope in your models to be used in select dropdowns.
|
21
35
|
|
22
36
|
Version 2.0 and higher are compatible with Rails 4 and Rails 3.2. dry_crud is tested with Ruby 1.9.3, 2.0.0 and JRuby. If you are using Ruby 1.8.7, please refer to version 1.7.0.
|
23
37
|
|
24
|
-
== Overview
|
25
38
|
|
26
|
-
|
39
|
+
== Background
|
40
|
+
|
41
|
+
In most Rails applications, you have some models that require basic CRUD (create, read, update, delete) functionality. There are various possibilities like Rails scaffolding, {Inherited Resources}[https://github.com/josevalim/inherited_resources] or {Rails Admin}[https://github.com/sferik/rails_admin]. Still, various parts in your application remain duplicated. While you might pull up common methods into a common superclass controller, most views still contain very similar code. And then you also have to remember the entire API of these frameworks.
|
27
42
|
|
28
43
|
Enter dry_crud.
|
29
44
|
|
@@ -35,24 +50,18 @@ dry_crud is a Rails generator. All code resides in your application and is open
|
|
35
50
|
|
36
51
|
dry_crud does not depend on any other plugins, but easily allows you to integrate them in order to unify the behavior of your CRUD controllers. You might even use the plugins mentioned above to adapt your generated CrudController base class. All classes come with thorough tests that provide you with a solid foundation for implementing your own adaptions.
|
37
52
|
|
38
|
-
A basic CSS gets you started with your application's layout. For advanced needs, dry_crud supports the styles and classes used in {Bootstrap}[http://
|
53
|
+
A basic CSS gets you started with your application's layout. For advanced needs, dry_crud supports the styles and classes used in {Bootstrap 3}[http://getbootstrap.com]. A great design never was so close.
|
39
54
|
|
40
55
|
If you find yourself adapting the same parts of dry_crud for your applications over and over, please feel free to {fork me on Github}[http://github.com/codez/dry_crud].
|
41
56
|
|
42
57
|
See the Examples section for some use cases and the Generated Files section below for details on the single classes and templates.
|
43
58
|
|
59
|
+
|
44
60
|
== Examples
|
45
61
|
|
46
62
|
=== Controller with CRUD functionality
|
47
63
|
|
48
|
-
Say you want to manage a +Person+ model.
|
49
|
-
|
50
|
-
<tt>app/controllers/people_controller.rb</tt>:
|
51
|
-
class PeopleController < CrudController
|
52
|
-
self.permitted_attrs = [:firstname, :lastname, :birthday, :sex, :city_id]
|
53
|
-
end
|
54
|
-
|
55
|
-
The +permitted_attrs+ define the parameter attributes allowed when creating or updating a model entry (see {Strong Paramters}[http://api.rubyonrails.org/classes/ActionController/StrongParameters.html]).
|
64
|
+
Say you want to manage a +Person+ model. Overwrite the +to_s+ method of your model for a human-friendly representation used in page titles.
|
56
65
|
|
57
66
|
<tt>app/models/person.rb</tt>:
|
58
67
|
class Person
|
@@ -61,6 +70,13 @@ The +permitted_attrs+ define the parameter attributes allowed when creating or u
|
|
61
70
|
end
|
62
71
|
end
|
63
72
|
|
73
|
+
Then create the following controller. The +permitted_attrs+ define the attribute parameters allowed when creating or updating a model entry (see {Strong Paramters}[http://api.rubyonrails.org/classes/ActionController/StrongParameters.html]).
|
74
|
+
|
75
|
+
<tt>app/controllers/people_controller.rb</tt>:
|
76
|
+
class PeopleController < CrudController
|
77
|
+
self.permitted_attrs = [:firstname, :lastname, :birthday, :sex, :city_id]
|
78
|
+
end
|
79
|
+
|
64
80
|
That's it. You have a sortable overview of all people, detail pages and forms to edit and create people. Of course, you may delete people as well. By default, all attributes are displayed and formatted according to their column type wherever they appear. This applies for the input fields as well.
|
65
81
|
|
66
82
|
|
@@ -78,7 +94,6 @@ This only displays these three attributes in the table. All other templates, as
|
|
78
94
|
Next, let's adapt a part of the general behavior used in all CRUD controllers. As an example, we include pagination with kaminari[https://github.com/amatsuda/kaminari] in all our overview tables:
|
79
95
|
|
80
96
|
In <tt>app/controllers/list_controller.rb</tt>, change the list_entries method to
|
81
|
-
|
82
97
|
def list_entries
|
83
98
|
model_scope.page(params[:page])
|
84
99
|
end
|
@@ -105,7 +120,12 @@ By the way: The method +f+ in FormatHelper uniformly formats arbitrary values ac
|
|
105
120
|
|
106
121
|
==== Sorting and filtering the index list
|
107
122
|
|
108
|
-
The entries listed on the index page are automatically sortable by each displayed database column. To apply a default sorting order, define
|
123
|
+
The entries listed on the index page are automatically sortable by each displayed database column. To apply a default sorting order, define a +list+ scope in your model:
|
124
|
+
|
125
|
+
In <tt>app/models/person.rb</tt>:
|
126
|
+
scope :list, -> { order('lastname, firstname').includes(:city) }
|
127
|
+
|
128
|
+
Alternatively, set the following class attribute in the controller:
|
109
129
|
|
110
130
|
In <tt>app/controllers/people_controller.rb</tt>:
|
111
131
|
self.default_sort = 'lastname, firstname'
|
@@ -163,7 +183,7 @@ Of course, custom input fields may be defined as well:
|
|
163
183
|
<%= f.labeled_file_field :picture %>
|
164
184
|
<% end %>
|
165
185
|
|
166
|
-
Even +belongs_to+ associations are automatically rendered with a select field. By default,
|
186
|
+
Even +belongs_to+ associations are automatically rendered with a select field. By default, entries returned from the +options_list+ scope of the associated model are used as options (if defined, all otherwise). To customize this, either define an instance variable with the same name as the association in your controller, or pass a <tt>list</tt> option:
|
167
187
|
<%= f.belongs_to_field :hometown, list: City.where(country: @person.country) %>
|
168
188
|
|
169
189
|
Yes, it's bad practice to use finder logic in your views! Define the variable <tt>@hometowns</tt> in your controller instead (as shown in the example above), and you do not even have to specify the <tt>list</tt> option.
|
@@ -238,40 +258,53 @@ Otherwise, the lookup for the title would fallback on the ListController's key <
|
|
238
258
|
This lookup mechanism also allows you to easily define per-controller overridable text snippets in your views.
|
239
259
|
|
240
260
|
|
261
|
+
=== Example Code
|
262
|
+
|
263
|
+
To see an example application built on dry_crud, have a look at {these directories}[https://github.com/codez/dry_crud/tree/master/test/templates/app]. Only certain methods and templates are overriden, all the 'missing' files are provided by dry_crud.
|
264
|
+
|
265
|
+
|
241
266
|
== Generated Files
|
242
267
|
|
243
268
|
All generated files are supposed to provide a reasonable foundation for the CRUD functionality. You are encouraged to adapt them to fit the needs of your application. They're yours!
|
244
269
|
|
245
|
-
=== Controller
|
270
|
+
=== Controller
|
246
271
|
|
247
|
-
{controller/crud_controller.rb}[http://codez.ch/dry_crud?q=CrudController]:: Abstract controller providing basic CRUD actions. This implementation mainly follows the one of the Rails scaffolding controller and responses to HTML and
|
272
|
+
{controller/crud_controller.rb}[http://codez.ch/dry_crud?q=CrudController]:: Abstract controller providing basic CRUD actions. This implementation mainly follows the one of the Rails scaffolding controller and responses to HTML and JSON requests. Some enhancements were made to ease extendability. Several protected helper methods are there to be (optionally) overriden by subclasses. With the help of additional callbacks, it is possible to hook into the action procedures without overriding the entire method. This class is based on ListController.
|
248
273
|
|
249
274
|
{controller/list_controller.rb}[http://codez.ch/dry_crud?q=ListController]:: Abstract controller providing a basic list action. Use this controller if you require read-only functionality. It includes the following modules.
|
250
275
|
|
251
|
-
{controller/
|
276
|
+
{controller/dry_crud/generic_model.rb}[http://codez.ch/dry_crud?q=DryCrud::GenericModel]:: Work with the model whose name corrsponds to the controller's name.
|
252
277
|
|
253
|
-
{controller/
|
278
|
+
{controller/dry_crud/nestable.rb}[http://codez.ch/dry_crud?q=DryCrud::Nestable]:: Provides functionality to easily nest controllers/resources.
|
254
279
|
|
255
|
-
{controller/
|
280
|
+
{controller/dry_crud/rememberable.rb}[http://codez.ch/dry_crud?q=DryCrud::Rememberable]:: Remembers certain params of the index action in order to return to the same list after an entry was viewed or edited.
|
256
281
|
|
257
|
-
{controller/
|
282
|
+
{controller/dry_crud/searchable.rb}[http://codez.ch/dry_crud?q=DryCrud::Searchable]:: Search functionality for the index table.
|
258
283
|
|
259
|
-
{controller/
|
284
|
+
{controller/dry_crud/sortable.rb}[http://codez.ch/dry_crud?q=DryCrud::Sortable]:: Sort functionality for the index table.
|
260
285
|
|
261
|
-
{controller/
|
286
|
+
{controller/dry_crud/render_callbacks.rb}[http://codez.ch/dry_crud?q=DryCrud::RenderCallbacks]:: Provide +before_render+ callbacks to controllers.
|
262
287
|
|
263
|
-
{controller/
|
288
|
+
{controller/dry_crud/responder.rb}[http://codez.ch/dry_crud?q=DryCrud::Responder]:: Responder used by the CrudController to handle the +path_args+.
|
264
289
|
|
265
|
-
=== Helpers
|
290
|
+
=== Helpers
|
266
291
|
|
267
|
-
{helpers/
|
292
|
+
{helpers/dry_crud/form/builder.rb}[http://codez.ch/dry_crud?q=DryCrud::Form::Builder]:: A form builder that automatically selects the corresponding input type for ActiveRecord columns. Input elements are rendered together with a label by default.
|
268
293
|
|
269
|
-
{helpers/
|
294
|
+
{helpers/dry_crud/form/control.rb}[http://codez.ch/dry_crud?q=DryCrud::Form::Control]:: Representation of a single form control consisting of a label, input field, addon or help text.
|
270
295
|
|
271
|
-
{helpers/
|
296
|
+
{helpers/dry_crud/table/builder.rb}[http://codez.ch/dry_crud?q=DryCrud::Table::Builder]:: A helper object to easily define tables listing several rows of the same data type.
|
297
|
+
|
298
|
+
{helpers/dry_crud/table/col.rb}[http://codez.ch/dry_crud?q=DryCrud::Table::Col]:: Helper class representing a single table column.
|
299
|
+
|
300
|
+
{helpers/dry_crud/table/actions.rb}[http://codez.ch/dry_crud?q=DryCrud::Table::Actions]:: Module to add support for uniform CRUD actions in tables.
|
301
|
+
|
302
|
+
{helpers/dry_crud/table/sorting.rb}[http://codez.ch/dry_crud?q=DryCrud::Table::Sorting]:: Module to add support for sort links in table headers.
|
272
303
|
|
273
304
|
{helpers/form_helper.rb}[http://codez.ch/dry_crud?q=FormHelper]:: Create forms to edit models with Crud::FormBuilder. Contains a standardized and a custom definable form.
|
274
305
|
|
306
|
+
{helpers/table_helper.rb}[http://codez.ch/dry_crud?q=TableHelper]:: Create tables to list multiple models with Crud::TableBuilder. Contains a standardized and a custom definable table.
|
307
|
+
|
275
308
|
{helpers/format_helper.rb}[http://codez.ch/dry_crud?q=FormatHelper]:: Format attribute and basic values according to their database or Ruby type.
|
276
309
|
|
277
310
|
{helpers/actions_helper.rb}[http://codez.ch/dry_crud?q=ActionsHelper]:: Uniform action links for the most common crud actions.
|
@@ -282,9 +315,10 @@ All generated files are supposed to provide a reasonable foundation for the CRUD
|
|
282
315
|
|
283
316
|
|
284
317
|
|
285
|
-
=== Views
|
318
|
+
=== Views
|
286
319
|
|
287
320
|
All templates in the +list+ and +crud+ folders may be 'overriden' individually in a respective view folder. Define the basic structure of your CRUD views here and adapt it as required for each single model. Actually, the <tt>_list.html.erb</tt> partial from the +list+ folder gets overriden in the +crud+ folder already.
|
321
|
+
|
288
322
|
All templates are available as HAML as well.
|
289
323
|
|
290
324
|
==== List
|
@@ -323,7 +357,7 @@ views/shared/_labeled.html.erb:: Partial to define the layout for an arbitrary c
|
|
323
357
|
|
324
358
|
views/shared/_error_messages.html.erb:: Partial to display the validation errors in Rails 2 style.
|
325
359
|
|
326
|
-
views/layouts/
|
360
|
+
views/layouts/application.html.erb:: An example layout showing how to use the <tt>@title</tt> and +flash+.
|
327
361
|
|
328
362
|
views/layouts/_flash.html.erb:: An simple partial to display the various flash messages. Included from <tt>crud.html.erb</tt>.
|
329
363
|
|
@@ -334,7 +368,7 @@ app/assets/stylesheets/crud.scss:: A simple SCSS with all the classes and ids us
|
|
334
368
|
app/assets/images/action/*.png:: Some sample action icons from the {Open Icon Library}[http://openiconlibrary.sourceforge.net].
|
335
369
|
|
336
370
|
|
337
|
-
=== Tests
|
371
|
+
=== Tests
|
338
372
|
|
339
373
|
test/support/crud_test_model.rb:: A dummy model to run CRUD tests against.
|
340
374
|
|
@@ -347,7 +381,7 @@ test/controllers/crud_test_models_controller_test.rb:: Functional tests for the
|
|
347
381
|
test/helpers/*_test.rb:: Tests for the provided helper implementations and a great base to test your adaptions of the CRUD code.
|
348
382
|
|
349
383
|
|
350
|
-
=== Specs
|
384
|
+
=== Specs
|
351
385
|
|
352
386
|
spec/support/crud_controller_examples.rb:: A whole set of shared exampled to include into your controller specs. See <tt>spec/controllers/crud_test_models_controller_spec.rb</tt> for usage. So for each new CRUD controller, you get all the basic specs for free.
|
353
387
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
h1 {
|
3
|
+
margin-bottom: 20px;
|
4
|
+
}
|
5
|
+
|
2
6
|
.right {
|
3
7
|
text-align: right;
|
4
8
|
}
|
@@ -8,9 +12,12 @@
|
|
8
12
|
}
|
9
13
|
|
10
14
|
#content {
|
15
|
+
padding-top: 10px;
|
16
|
+
}
|
17
|
+
|
18
|
+
#flash {
|
11
19
|
clear: both;
|
12
20
|
padding-top: 5px;
|
13
|
-
width: 100%;
|
14
21
|
}
|
15
22
|
|
16
23
|
table.table td.action {
|
@@ -18,32 +25,11 @@ table.table td.action {
|
|
18
25
|
text-align: center;
|
19
26
|
}
|
20
27
|
|
21
|
-
.control-group {
|
22
|
-
clear: both;
|
23
|
-
padding: 2px 0 2px;
|
24
|
-
}
|
25
|
-
|
26
|
-
.control-group label {
|
27
|
-
float: left;
|
28
|
-
width: 120px;
|
29
|
-
padding-right: 5px;
|
30
|
-
}
|
31
|
-
|
32
|
-
.controls {
|
33
|
-
margin-left: 130px;
|
34
|
-
}
|
35
|
-
|
36
28
|
.cancel {
|
37
29
|
font-size: 80%;
|
38
30
|
margin-left: 7px;
|
39
31
|
}
|
40
32
|
|
41
|
-
.required {
|
42
|
-
font-size: 80%;
|
43
|
-
vertical-align: top;
|
44
|
-
margin-left: 2px;
|
45
|
-
}
|
46
|
-
|
47
33
|
#error_explanation h2 {
|
48
34
|
font-size: 100%;
|
49
35
|
margin-top: 0px;
|
@@ -53,3 +39,7 @@ table.table td.action {
|
|
53
39
|
margin-bottom: 5px;
|
54
40
|
}
|
55
41
|
|
42
|
+
footer {
|
43
|
+
clear: both;
|
44
|
+
}
|
45
|
+
|