cruddler 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +141 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +173 -0
- data/Rakefile +40 -0
- data/cruddler.gemspec +23 -0
- data/lib/cruddler.rb +33 -0
- data/lib/cruddler/controller.rb +186 -0
- data/lib/cruddler/crud_actions.rb +118 -0
- data/lib/cruddler/engine.rb +28 -0
- data/lib/cruddler/path_helpers.rb +100 -0
- data/lib/cruddler/version.rb +26 -0
- data/lib/generators/cruddler/install/USAGE +8 -0
- data/lib/generators/cruddler/install/install_generator.rb +40 -0
- data/lib/generators/cruddler/install/templates/application/edit.html.erb +18 -0
- data/lib/generators/cruddler/install/templates/application/index.html.erb +13 -0
- data/lib/generators/cruddler/install/templates/application/new.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/application/show.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/cruddler.yml +21 -0
- data/lib/tasks/cruddler_tasks.rake +4 -0
- data/script/rails +8 -0
- data/test/cruddler_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/cats.js +2 -0
- data/test/dummy/app/assets/javascripts/dogs.js +2 -0
- data/test/dummy/app/assets/javascripts/houses.js +2 -0
- data/test/dummy/app/assets/javascripts/parasites.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/cats.css +4 -0
- data/test/dummy/app/assets/stylesheets/dogs.css +4 -0
- data/test/dummy/app/assets/stylesheets/houses.css +4 -0
- data/test/dummy/app/assets/stylesheets/parasites.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/cats_controller.rb +7 -0
- data/test/dummy/app/controllers/dogs_controller.rb +11 -0
- data/test/dummy/app/controllers/houses_controller.rb +6 -0
- data/test/dummy/app/controllers/parasites_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/cats_helper.rb +2 -0
- data/test/dummy/app/helpers/dogs_helper.rb +2 -0
- data/test/dummy/app/helpers/houses_helper.rb +2 -0
- data/test/dummy/app/helpers/parasites_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/cat.rb +4 -0
- data/test/dummy/app/models/dog.rb +3 -0
- data/test/dummy/app/models/house.rb +5 -0
- data/test/dummy/app/models/parasite.rb +3 -0
- data/test/dummy/app/views/application/edit.html.erb +18 -0
- data/test/dummy/app/views/application/index.html.erb +13 -0
- data/test/dummy/app/views/application/new.html.erb +17 -0
- data/test/dummy/app/views/application/show.html.erb +17 -0
- data/test/dummy/app/views/cats/_form.html.erb +15 -0
- data/test/dummy/app/views/cats/_listing.html.erb +23 -0
- data/test/dummy/app/views/cats/_show_cat.html.erb +10 -0
- data/test/dummy/app/views/dogs/_form.html.erb +21 -0
- data/test/dummy/app/views/dogs/_listing.html.erb +23 -0
- data/test/dummy/app/views/dogs/_show_dog.html.erb +10 -0
- data/test/dummy/app/views/houses/_form.html.erb +25 -0
- data/test/dummy/app/views/houses/_listing.html.erb +23 -0
- data/test/dummy/app/views/houses/_show_house.html.erb +11 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/parasites/_form.html.erb +25 -0
- data/test/dummy/app/views/parasites/_listing.html.erb +27 -0
- data/test/dummy/app/views/parasites/_show_parasite.html.erb +19 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +12 -0
- data/test/dummy/db/migrate/20120606105838_create_houses.rb +10 -0
- data/test/dummy/db/migrate/20120606110003_create_cats.rb +11 -0
- data/test/dummy/db/migrate/20120606110348_create_dogs.rb +13 -0
- data/test/dummy/db/migrate/20120606175547_create_parasites.rb +12 -0
- data/test/dummy/db/schema.rb +53 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/cruddler_integration_test.rb +253 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/support/capybara.rb +29 -0
- data/test/test_helper.rb +15 -0
- metadata +253 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1016297865fd98aad79facd7151455c2f5f3c0da
|
4
|
+
data.tar.gz: 488775e99382a07ac3d7113ff786855c7232069d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86597b3b0dfbc054d667352f1be1b88b68d4459ea05fb27ead46538517d73f682ffd804dd32d2dce8898820ac1f32f77adef4c562cb1c59f680c0b3b60d6f7a9
|
7
|
+
data.tar.gz: 37470a87d451f526a7ed632ca45ad075c69d46b0cea795062c1fab535916e94f6dabac87835118cac63d67b32f4bb1aa7e3d84be63446f6a76bbc1c8f1f85e07
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in cruddler.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
gem "jquery-rails"
|
10
|
+
gem "tabulatr"
|
11
|
+
gem "sqlite3"
|
12
|
+
gem "simple_form"
|
13
|
+
|
14
|
+
# Declare any dependencies that are still in development here instead of in
|
15
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
16
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
17
|
+
# your gem to rubygems.org.
|
18
|
+
|
19
|
+
# To use debugger
|
20
|
+
gem 'debugger'
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
gem 'factory_girl_rails'
|
24
|
+
gem 'database_cleaner'
|
25
|
+
gem 'capybara'
|
26
|
+
gem 'capybara-webkit'
|
27
|
+
gem 'chromedriver-helper'
|
28
|
+
gem 'launchy'
|
29
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cruddler (4.0.0a)
|
5
|
+
rails (>= 4.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.0.0)
|
11
|
+
actionpack (= 4.0.0)
|
12
|
+
mail (~> 2.5.3)
|
13
|
+
actionpack (4.0.0)
|
14
|
+
activesupport (= 4.0.0)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
activemodel (4.0.0)
|
20
|
+
activesupport (= 4.0.0)
|
21
|
+
builder (~> 3.1.0)
|
22
|
+
activerecord (4.0.0)
|
23
|
+
activemodel (= 4.0.0)
|
24
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
25
|
+
activesupport (= 4.0.0)
|
26
|
+
arel (~> 4.0.0)
|
27
|
+
activerecord-deprecated_finders (1.0.3)
|
28
|
+
activesupport (4.0.0)
|
29
|
+
i18n (~> 0.6, >= 0.6.4)
|
30
|
+
minitest (~> 4.2)
|
31
|
+
multi_json (~> 1.3)
|
32
|
+
thread_safe (~> 0.1)
|
33
|
+
tzinfo (~> 0.3.37)
|
34
|
+
addressable (2.3.5)
|
35
|
+
arel (4.0.0)
|
36
|
+
atomic (1.1.10)
|
37
|
+
builder (3.1.4)
|
38
|
+
capybara (2.1.0)
|
39
|
+
mime-types (>= 1.16)
|
40
|
+
nokogiri (>= 1.3.3)
|
41
|
+
rack (>= 1.0.0)
|
42
|
+
rack-test (>= 0.5.4)
|
43
|
+
xpath (~> 2.0)
|
44
|
+
capybara-webkit (1.0.0)
|
45
|
+
capybara (~> 2.0, >= 2.0.2)
|
46
|
+
json
|
47
|
+
chromedriver-helper (0.0.5)
|
48
|
+
nokogiri
|
49
|
+
columnize (0.3.6)
|
50
|
+
database_cleaner (1.0.1)
|
51
|
+
debugger (1.6.1)
|
52
|
+
columnize (>= 0.3.1)
|
53
|
+
debugger-linecache (~> 1.2.0)
|
54
|
+
debugger-ruby_core_source (~> 1.2.3)
|
55
|
+
debugger-linecache (1.2.0)
|
56
|
+
debugger-ruby_core_source (1.2.3)
|
57
|
+
erubis (2.7.0)
|
58
|
+
factory_girl (4.2.0)
|
59
|
+
activesupport (>= 3.0.0)
|
60
|
+
factory_girl_rails (4.2.1)
|
61
|
+
factory_girl (~> 4.2.0)
|
62
|
+
railties (>= 3.0.0)
|
63
|
+
hike (1.2.3)
|
64
|
+
i18n (0.6.4)
|
65
|
+
id_stuffer (0.0.1)
|
66
|
+
jquery-rails (3.0.4)
|
67
|
+
railties (>= 3.0, < 5.0)
|
68
|
+
thor (>= 0.14, < 2.0)
|
69
|
+
json (1.8.0)
|
70
|
+
launchy (2.3.0)
|
71
|
+
addressable (~> 2.3)
|
72
|
+
mail (2.5.4)
|
73
|
+
mime-types (~> 1.16)
|
74
|
+
treetop (~> 1.4.8)
|
75
|
+
mime-types (1.23)
|
76
|
+
mini_portile (0.5.1)
|
77
|
+
minitest (4.7.5)
|
78
|
+
multi_json (1.7.7)
|
79
|
+
nokogiri (1.6.0)
|
80
|
+
mini_portile (~> 0.5.0)
|
81
|
+
polyglot (0.3.3)
|
82
|
+
rack (1.5.2)
|
83
|
+
rack-test (0.6.2)
|
84
|
+
rack (>= 1.0)
|
85
|
+
rails (4.0.0)
|
86
|
+
actionmailer (= 4.0.0)
|
87
|
+
actionpack (= 4.0.0)
|
88
|
+
activerecord (= 4.0.0)
|
89
|
+
activesupport (= 4.0.0)
|
90
|
+
bundler (>= 1.3.0, < 2.0)
|
91
|
+
railties (= 4.0.0)
|
92
|
+
sprockets-rails (~> 2.0.0)
|
93
|
+
railties (4.0.0)
|
94
|
+
actionpack (= 4.0.0)
|
95
|
+
activesupport (= 4.0.0)
|
96
|
+
rake (>= 0.8.7)
|
97
|
+
thor (>= 0.18.1, < 2.0)
|
98
|
+
rake (10.1.0)
|
99
|
+
simple_form (1.4.1)
|
100
|
+
sprockets (2.10.0)
|
101
|
+
hike (~> 1.2)
|
102
|
+
multi_json (~> 1.0)
|
103
|
+
rack (~> 1.0)
|
104
|
+
tilt (~> 1.1, != 1.3.0)
|
105
|
+
sprockets-rails (2.0.0)
|
106
|
+
actionpack (>= 3.0)
|
107
|
+
activesupport (>= 3.0)
|
108
|
+
sprockets (~> 2.8)
|
109
|
+
sqlite3 (1.3.7)
|
110
|
+
tabulatr (0.4.2)
|
111
|
+
id_stuffer (>= 0.0.1)
|
112
|
+
rails (>= 3.0.0)
|
113
|
+
whiny_hash (>= 0.0.2)
|
114
|
+
thor (0.18.1)
|
115
|
+
thread_safe (0.1.2)
|
116
|
+
atomic
|
117
|
+
tilt (1.4.1)
|
118
|
+
treetop (1.4.14)
|
119
|
+
polyglot
|
120
|
+
polyglot (>= 0.3.1)
|
121
|
+
tzinfo (0.3.37)
|
122
|
+
whiny_hash (0.0.2)
|
123
|
+
xpath (2.0.0)
|
124
|
+
nokogiri (~> 1.3)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
ruby
|
128
|
+
|
129
|
+
DEPENDENCIES
|
130
|
+
capybara
|
131
|
+
capybara-webkit
|
132
|
+
chromedriver-helper
|
133
|
+
cruddler!
|
134
|
+
database_cleaner
|
135
|
+
debugger
|
136
|
+
factory_girl_rails
|
137
|
+
jquery-rails
|
138
|
+
launchy
|
139
|
+
simple_form
|
140
|
+
sqlite3
|
141
|
+
tabulatr
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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.
|
data/README.textile
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
h1. Cruddler - CRUD admin controllers for lazy programmers
|
2
|
+
|
3
|
+
NOTE: This is currently in in-house-testing-and-developing state. Feel free to use, but don't complain if it doesn't fit your needs. Feedback is welcome, though.
|
4
|
+
|
5
|
+
h2. Mission Objective
|
6
|
+
|
7
|
+
I was sick of implementing edit, show, index, ... actions over and over again, and wasn't too enthusiastic about resource_controller and the like for they are way to overengineered.
|
8
|
+
|
9
|
+
The same annoyance I found in implementing the corresponding view.
|
10
|
+
|
11
|
+
And now, Rails 3.1 is there with view inheritance.
|
12
|
+
|
13
|
+
h2. Installaton
|
14
|
+
|
15
|
+
add to your Gemfile:
|
16
|
+
|
17
|
+
<pre>
|
18
|
+
gem 'cruddler'
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
and install the view-inheritance views:
|
22
|
+
|
23
|
+
<pre>
|
24
|
+
rails g cruddler:install
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
This installs the index, show, new, edit files to <tt>app/views/admin/application/</tt>, if you want to use them elsewhere, just move them around as you like :)
|
28
|
+
|
29
|
+
It also installs a <tt>cruddler.yml</tt> locale file as described below in i18n.
|
30
|
+
|
31
|
+
h2. Controller
|
32
|
+
|
33
|
+
just write
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
cruddler :all
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
into your controller, or replace <tt>:all</tt> with a list of the actions you want to generate.
|
40
|
+
|
41
|
+
h3. Options
|
42
|
+
|
43
|
+
* <tt>:klass => </tt> the resource class, if it can't be guessed from the controller name
|
44
|
+
* <tt>:parameter_name => </tt> the name of the <tt>params</tt> entry, also used as the name of the instance variable generated
|
45
|
+
* <tt>:nested => </tt> if the current resource is nested, either give the name of the nesting model, an array of the names of nesting models, or a hash <tt>{:model1 => Model1, :model2 => Model2, ...}</tt> if the name/model connection can't be guessed.
|
46
|
+
* <tt>:nested_as => </tt> the name of the current resource inside the nesting model, if it can't be guessed. Usually necessary for polymorphic nestings
|
47
|
+
* <tt>:path_components => </tt> an array of path components like <tt>[:admin, :catalog]</tt> if they can't be guessed from the controller name
|
48
|
+
* <tt>:authorize => </tt> <tt>true</tt> if <a href="https://github.com/ryanb/cancan">cancan</a> <tt>authorize!</tt> is to be called for the current resource
|
49
|
+
* <tt>:index_path => </tt> either a string, a symbol (<tt>:index, :show, :edit, :new</tt>) or a <tt>proc</tt> to declare the <tt>index</tt> path for redirects
|
50
|
+
* <tt>:after_update_path => </tt> either a string, a symbol (<tt>:index, :show, :edit, :new</tt>) or a <tt>proc</tt> to declare where to redirect after updates
|
51
|
+
* <tt>:after_create_path => </tt> either a string, a symbol (<tt>:index, :show, :edit, :new</tt>) or a <tt>proc</tt> to declare where to redirect after create
|
52
|
+
* <tt>:after_destroy_path => </tt> either a string, a symbol (<tt>:index, :show, :edit, :new</tt>) or a <tt>proc</tt> to declare where to redirect after destroy
|
53
|
+
* <tt>:stateful_index => </tt> if tabulatr is available, the <tt>find_for_table</tt> call geht the <tt>:stateful => session</tt> option.
|
54
|
+
|
55
|
+
We intentionally don't offer any callbacks or the like, for typical CRUD actions are sufficiently simple to just implement them if they are non-standard. So -- It you're not happy with what cruddler generated, just implement your action 'by hand'.
|
56
|
+
|
57
|
+
BTW: If <a href="http://github.com/metaminded/tabulatr">tabulatr</a> is available, the generated <tt>index</tt> action uses <tt>find_for_table</tt> instead of <tt>find</tt>.
|
58
|
+
|
59
|
+
h3. Strong Parameters
|
60
|
+
|
61
|
+
To use strong parameters in rails 4, you have the following options:
|
62
|
+
|
63
|
+
Give block to generate house_parameters method
|
64
|
+
|
65
|
+
<pre>
|
66
|
+
class HousesController < ApplicationController
|
67
|
+
cruddler :all do
|
68
|
+
params.required(:house).permit(:name, :number)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
</pre>
|
72
|
+
|
73
|
+
Give <tt>permit_params</tt> option to implicitly define <tt>cat_params</tt> method:
|
74
|
+
|
75
|
+
<tt>params.required(:cat).permit(:name)</tt>
|
76
|
+
|
77
|
+
<pre>
|
78
|
+
class CatsController < ApplicationController
|
79
|
+
cruddler :all,
|
80
|
+
nested: 'house',
|
81
|
+
index_path: ->(){ house_cats_path(@house) },
|
82
|
+
permit_params: [:name]
|
83
|
+
end
|
84
|
+
</pre>
|
85
|
+
|
86
|
+
Give <tt>permit_params: :all</tt> option to implicitly define <tt>cat_params</tt> method:
|
87
|
+
|
88
|
+
<tt>params.required(:parasite).permit!</tt>
|
89
|
+
|
90
|
+
<pre>
|
91
|
+
class ParasitesController < ApplicationController
|
92
|
+
cruddler :all,
|
93
|
+
nested: ['house', 'cat'],
|
94
|
+
index_path: ->(){ house_cat_parasites_path(@house, @cat) },
|
95
|
+
permit_params: :all
|
96
|
+
end
|
97
|
+
</pre>
|
98
|
+
|
99
|
+
Give <tt>permit_params: ->(){ closure }</tt> option to implicitly define dynamic <tt>cat_params</tt> method:
|
100
|
+
|
101
|
+
<tt>params.required(:dog).permit(<evaluation of closure>)</tt>
|
102
|
+
|
103
|
+
<pre>
|
104
|
+
class DogsController < ApplicationController
|
105
|
+
cruddler :all,
|
106
|
+
nested: 'house',
|
107
|
+
nested_as: 'ref',
|
108
|
+
permit_params: ->(){ @house.id == 2 ? :name : [] }
|
109
|
+
end
|
110
|
+
</pre>
|
111
|
+
|
112
|
+
h3. Dealing with non-standard queries
|
113
|
+
|
114
|
+
In the standard case, cruddler uses the plain <tt>FooBar</tt> model in the <tt>FooBarController</tt>.
|
115
|
+
If you want to change this behavior, override <tt>cruddler_find_on</tt> in your controller.
|
116
|
+
The example below uses the unscoped model:
|
117
|
+
|
118
|
+
<pre>
|
119
|
+
def cruddler_find_on
|
120
|
+
FooBar.unscoped
|
121
|
+
end
|
122
|
+
</pre>
|
123
|
+
|
124
|
+
h2. Views
|
125
|
+
|
126
|
+
Just implement <tt>_model_name</tt>, and <tt>_listing</tt> partials, the rest is done magically. If your edit or new actions need to be more specific, you can override with <tt>_edit_model_name</tt> or <tt>_new_model_name</tt>.
|
127
|
+
|
128
|
+
As with the controllers, we don't offer fancy customization options. If you don't like the views, go to the cruddler gem, copy the views into your project, and customize them to your needs.
|
129
|
+
|
130
|
+
h2. I18n
|
131
|
+
|
132
|
+
In the views and flash-messages, we use i18n, here's an example, you get the idea:
|
133
|
+
|
134
|
+
<pre>
|
135
|
+
en:
|
136
|
+
cruddler:
|
137
|
+
abort: "Abort"
|
138
|
+
admin: # path elements if necessary
|
139
|
+
product:
|
140
|
+
edit: "Edit product '%{name}'"
|
141
|
+
index: "All our Products"
|
142
|
+
create: "Create new Product"
|
143
|
+
new: "Create new Product"
|
144
|
+
update_success: "Product updated"
|
145
|
+
update_problem: "Product can't be saved"
|
146
|
+
create_success: "Product created"
|
147
|
+
create_problem: "Product can't be created"
|
148
|
+
</pre>
|
149
|
+
|
150
|
+
h3. Bugs
|
151
|
+
|
152
|
+
There may be lots of bugs in cruddler, although we do some testing (see <tt>spec/</tt>). So if you hunt them, please let me know using the <a href="https://github.com/metaminded/cruddler/issues">GitHub Bugtracker</a>.
|
153
|
+
|
154
|
+
h2. Contributing to cruddler
|
155
|
+
|
156
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
157
|
+
* Check out the <a href="https://github.com/metaminded/cruddler/issues">issue tracker</a> to make sure someone already hasn't requested it and/or contributed it
|
158
|
+
* Fork the project
|
159
|
+
* Start a feature/bugfix branch
|
160
|
+
* Commit and push until you are happy with your contribution
|
161
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
162
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
163
|
+
* Feel free to send a pull request if you think others (me, for example) would like to have your change incorporated into future versions of cruddler.
|
164
|
+
|
165
|
+
h2. License
|
166
|
+
|
167
|
+
Copyright (c) 2010-2012 Peter Horn, <a href="http://www.metaminded.com" target="_blank">metaminded UG</a>
|
168
|
+
|
169
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
170
|
+
|
171
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
172
|
+
|
173
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Cruddler'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
data/cruddler.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "cruddler/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "cruddler"
|
7
|
+
s.version = Cruddler::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "CRUD Actions for Lazy Coders"
|
10
|
+
s.email = "open-source@metaminded.com"
|
11
|
+
s.homepage = "http://github.com/metaminded/cruddler"
|
12
|
+
s.description = "CRUD Actions for Lazy Coders, with just the correct amount of cifugurability."
|
13
|
+
s.authors = ['Peter Horn', 'Rene Sprotte']
|
14
|
+
s.licenses = ['MIT']
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = []
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rdoc_options = ['--charset=UTF-8']
|
20
|
+
|
21
|
+
|
22
|
+
s.add_runtime_dependency('rails', '~> 4.0', '>= 4.0.0')
|
23
|
+
end
|