hobo 2.0.0.pre7 → 2.0.0.pre8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES-1.4.txt +13 -13
- data/CHANGES-2.0.markdown +13 -13
- data/Gemfile +7 -1
- data/VERSION +1 -1
- data/app/helpers/hobo_route_helper.rb +8 -2
- data/hobo.gemspec +0 -1
- data/lib/generators/hobo/install_default_plugins/install_default_plugins_generator.rb +6 -2
- data/lib/generators/hobo/model/templates/model_injection.rb.erb +1 -1
- data/lib/generators/hobo/plugin.rb +1 -1
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +2 -2
- data/lib/hobo/controller.rb +4 -0
- data/lib/hobo/controller/model.rb +1 -0
- data/lib/hobo/controller/user_base.rb +8 -3
- data/lib/hobo/model/scopes/automatic_scopes.rb +8 -6
- data/test/doctest/hobo/controller.rdoctest +55 -12
- data/test/doctest/hobo/multi_model_forms.rdoctest +15 -5
- data/test/doctest/hobo/scopes.rdoctest +14 -7
- metadata +153 -148
data/CHANGES-1.4.txt
CHANGED
@@ -12,7 +12,7 @@ Contents
|
|
12
12
|
|
13
13
|
# Installation
|
14
14
|
|
15
|
-
Meta tags: note for collaborators. A meta-tag looks like this {.done}. It's added after a paragraph with no blank spaces. The tags that we support are: {.ruby} {.javascript} {.dryml} and {.diff} for code highlighting. {.todo}, {.done}, {.check}, {.part} and {.nomove} indicate documentation progress moving into the Hobo manuals. {.check} means that it's probably done. {.part} means that it's partly done. {.nomove} means that this section only needs to exist in this CHANGES document. Finally, {.hidden} is used for paragraphs like this one that shouldn't show up on the website.
|
15
|
+
Meta tags: note for collaborators. A meta-tag looks like this {.done}. It's added after a paragraph with no blank spaces. The tags that we support are: {.ruby} {.javascript} {.dryml} and {.diff} for code highlighting. {.todo}, {.done}, {.check}, {.part} and {.nomove} indicate documentation progress moving into the Hobo manuals. {.check} means that it's probably done. {.part} means that it's partly done. {.nomove} means that this section only needs to exist in this CHANGES document. Finally, {.hidden} is used for paragraphs like this one that shouldn't show up on the website.
|
16
16
|
{.hidden}
|
17
17
|
|
18
18
|
## Creating a new application
|
@@ -340,13 +340,12 @@ Hobo 2.0 currently requires Rails 3.2 for operation.
|
|
340
340
|
## Enhancements
|
341
341
|
|
342
342
|
### Nested caching
|
343
|
-
{.
|
343
|
+
{.done}
|
344
344
|
|
345
|
-
See the docs for `<nested-cache>` and the
|
346
|
-
eventually write...
|
345
|
+
See the docs for `<nested-cache>` and the [caching-tutorial](/tutorials/caching).
|
347
346
|
|
348
347
|
### push-state
|
349
|
-
{.
|
348
|
+
{.done}
|
350
349
|
|
351
350
|
AJAX now supports a new AJAX option 'push-state' if you have
|
352
351
|
History.js installed. It was inspired by [this
|
@@ -505,7 +504,7 @@ environment.
|
|
505
504
|
bottom-load-javascript is incompatible with turbolinks.
|
506
505
|
|
507
506
|
### allowing errors in parts
|
508
|
-
{.
|
507
|
+
{.done}
|
509
508
|
|
510
509
|
Older versions of Hobo did not render a part update if the update did
|
511
510
|
not pass validation.
|
@@ -561,7 +560,7 @@ itself, and passes the element as an argument.
|
|
561
560
|
</new-page>
|
562
561
|
|
563
562
|
### before callback
|
564
|
-
{.
|
563
|
+
{.done}
|
565
564
|
|
566
565
|
A new callback has been added to the list of Ajax Callbacks: before.
|
567
566
|
This callback fires before any Ajax is done. If you return false
|
@@ -570,7 +569,7 @@ explicitly return true if you use it and don't want your ajax
|
|
570
569
|
cancelled.
|
571
570
|
|
572
571
|
### callbacks
|
573
|
-
{.
|
572
|
+
{.done}
|
574
573
|
|
575
574
|
Normally in HTML you can attach either a snippet of javascript or a
|
576
575
|
function to a callback.
|
@@ -589,12 +588,12 @@ Now you can just return the function name:
|
|
589
588
|
<form ajax success="fbar"/>
|
590
589
|
|
591
590
|
### `hide` and `show` ajax options
|
592
|
-
{.
|
591
|
+
{.done}
|
593
592
|
|
594
593
|
There are two new ajax options: `hide` and `show`. These are passed
|
595
594
|
directly to the jQuery-UI `hide` and `show` functions. See
|
596
|
-
(
|
597
|
-
(
|
595
|
+
[here](http://jqueryui.com/demos/show/) and
|
596
|
+
[here](http://docs.jquery.com/UI/Effects) for more documentation on
|
598
597
|
these two functions. Due to ruby to javascript translation
|
599
598
|
difficulties, you may not drop optional middle parameters.
|
600
599
|
|
@@ -619,7 +618,7 @@ If, after changing the default you wish to disable effects on one specific ajax
|
|
619
618
|
Note that these effects require jQuery-UI. You will get Javascript errors if you attempt to use effects and do not have jQuery-UI installed.
|
620
619
|
|
621
620
|
### spinner options
|
622
|
-
{.
|
621
|
+
{.done}
|
623
622
|
|
624
623
|
By default, the spinner is now displayed next to the element being
|
625
624
|
updated. Besides the old `spinner-next-to` option, there are a number
|
@@ -764,6 +763,7 @@ There's a new helper function called query_parameters_filtered that
|
|
764
763
|
returns query parameters with the ajax parameters removed.
|
765
764
|
|
766
765
|
### parse_sort_param
|
766
|
+
{.done}
|
767
767
|
|
768
768
|
The controller function parse_sort_param has been updated so that it
|
769
769
|
can take a hash instead of or as well as an argument list. The key of
|
@@ -781,7 +781,7 @@ column "projects.title".
|
|
781
781
|
|
782
782
|
Hobo no longer attempts to perform its part-based AJAX actions when
|
783
783
|
sent an xhr request. Instead, Hobo performs part-based AJAX when
|
784
|
-
params[:render] is set.
|
784
|
+
`params[:render]` is set.
|
785
785
|
|
786
786
|
The signature for the function update_response, index_response and friends have changed. This should make it useful for use in your application. update_response is called automatically by hobo_update if you don't render or redirect inside of the block parameter hobo_update.
|
787
787
|
|
data/CHANGES-2.0.markdown
CHANGED
@@ -12,7 +12,7 @@ Contents
|
|
12
12
|
|
13
13
|
# Installation
|
14
14
|
|
15
|
-
Meta tags: note for collaborators. A meta-tag looks like this {.done}. It's added after a paragraph with no blank spaces. The tags that we support are: {.ruby} {.javascript} {.dryml} and {.diff} for code highlighting. {.todo}, {.done}, {.check}, {.part} and {.nomove} indicate documentation progress moving into the Hobo manuals. {.check} means that it's probably done. {.part} means that it's partly done. {.nomove} means that this section only needs to exist in this CHANGES document. Finally, {.hidden} is used for paragraphs like this one that shouldn't show up on the website.
|
15
|
+
Meta tags: note for collaborators. A meta-tag looks like this {.done}. It's added after a paragraph with no blank spaces. The tags that we support are: {.ruby} {.javascript} {.dryml} and {.diff} for code highlighting. {.todo}, {.done}, {.check}, {.part} and {.nomove} indicate documentation progress moving into the Hobo manuals. {.check} means that it's probably done. {.part} means that it's partly done. {.nomove} means that this section only needs to exist in this CHANGES document. Finally, {.hidden} is used for paragraphs like this one that shouldn't show up on the website.
|
16
16
|
{.hidden}
|
17
17
|
|
18
18
|
## Creating a new application
|
@@ -340,13 +340,12 @@ Hobo 2.0 currently requires Rails 3.2 for operation.
|
|
340
340
|
## Enhancements
|
341
341
|
|
342
342
|
### Nested caching
|
343
|
-
{.
|
343
|
+
{.done}
|
344
344
|
|
345
|
-
See the docs for `<nested-cache>` and the
|
346
|
-
eventually write...
|
345
|
+
See the docs for `<nested-cache>` and the [caching-tutorial](/tutorials/caching).
|
347
346
|
|
348
347
|
### push-state
|
349
|
-
{.
|
348
|
+
{.done}
|
350
349
|
|
351
350
|
AJAX now supports a new AJAX option 'push-state' if you have
|
352
351
|
History.js installed. It was inspired by [this
|
@@ -505,7 +504,7 @@ environment.
|
|
505
504
|
bottom-load-javascript is incompatible with turbolinks.
|
506
505
|
|
507
506
|
### allowing errors in parts
|
508
|
-
{.
|
507
|
+
{.done}
|
509
508
|
|
510
509
|
Older versions of Hobo did not render a part update if the update did
|
511
510
|
not pass validation.
|
@@ -561,7 +560,7 @@ itself, and passes the element as an argument.
|
|
561
560
|
</new-page>
|
562
561
|
|
563
562
|
### before callback
|
564
|
-
{.
|
563
|
+
{.done}
|
565
564
|
|
566
565
|
A new callback has been added to the list of Ajax Callbacks: before.
|
567
566
|
This callback fires before any Ajax is done. If you return false
|
@@ -570,7 +569,7 @@ explicitly return true if you use it and don't want your ajax
|
|
570
569
|
cancelled.
|
571
570
|
|
572
571
|
### callbacks
|
573
|
-
{.
|
572
|
+
{.done}
|
574
573
|
|
575
574
|
Normally in HTML you can attach either a snippet of javascript or a
|
576
575
|
function to a callback.
|
@@ -589,12 +588,12 @@ Now you can just return the function name:
|
|
589
588
|
<form ajax success="fbar"/>
|
590
589
|
|
591
590
|
### `hide` and `show` ajax options
|
592
|
-
{.
|
591
|
+
{.done}
|
593
592
|
|
594
593
|
There are two new ajax options: `hide` and `show`. These are passed
|
595
594
|
directly to the jQuery-UI `hide` and `show` functions. See
|
596
|
-
(
|
597
|
-
(
|
595
|
+
[here](http://jqueryui.com/demos/show/) and
|
596
|
+
[here](http://docs.jquery.com/UI/Effects) for more documentation on
|
598
597
|
these two functions. Due to ruby to javascript translation
|
599
598
|
difficulties, you may not drop optional middle parameters.
|
600
599
|
|
@@ -619,7 +618,7 @@ If, after changing the default you wish to disable effects on one specific ajax
|
|
619
618
|
Note that these effects require jQuery-UI. You will get Javascript errors if you attempt to use effects and do not have jQuery-UI installed.
|
620
619
|
|
621
620
|
### spinner options
|
622
|
-
{.
|
621
|
+
{.done}
|
623
622
|
|
624
623
|
By default, the spinner is now displayed next to the element being
|
625
624
|
updated. Besides the old `spinner-next-to` option, there are a number
|
@@ -764,6 +763,7 @@ There's a new helper function called query_parameters_filtered that
|
|
764
763
|
returns query parameters with the ajax parameters removed.
|
765
764
|
|
766
765
|
### parse_sort_param
|
766
|
+
{.done}
|
767
767
|
|
768
768
|
The controller function parse_sort_param has been updated so that it
|
769
769
|
can take a hash instead of or as well as an argument list. The key of
|
@@ -781,7 +781,7 @@ column "projects.title".
|
|
781
781
|
|
782
782
|
Hobo no longer attempts to perform its part-based AJAX actions when
|
783
783
|
sent an xhr request. Instead, Hobo performs part-based AJAX when
|
784
|
-
params[:render] is set.
|
784
|
+
`params[:render]` is set.
|
785
785
|
|
786
786
|
The signature for the function update_response, index_response and friends have changed. This should make it useful for use in your application. update_response is called automatically by hobo_update if you don't render or redirect inside of the block parameter hobo_update.
|
787
787
|
|
data/Gemfile
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem 'rubydoctest', :git => 'git://github.com/bryanlarsen/rubydoctest.git'
|
4
|
-
gem 'rails', '3.2.
|
4
|
+
gem 'rails', '3.2.11'
|
5
5
|
gemspec :path => "../dryml"
|
6
6
|
gemspec :path => "../hobo_support"
|
7
7
|
gemspec :path => "../hobo_fields"
|
8
8
|
gemspec
|
9
9
|
gem 'will_paginate', :git => 'git://github.com/Hobo/will_paginate.git'
|
10
|
+
platform :ruby do
|
11
|
+
gem 'sqlite3'
|
12
|
+
end
|
13
|
+
platform :jruby do
|
14
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
15
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.pre8
|
@@ -165,12 +165,18 @@ module HoboRouteHelper
|
|
165
165
|
def recognize_page_path
|
166
166
|
# round tripping params through the router will remove
|
167
167
|
# unnecessary params
|
168
|
-
|
168
|
+
if params[:page_path]
|
169
|
+
url = params[:page_path]
|
170
|
+
method = "GET"
|
171
|
+
else
|
172
|
+
url = url_for(params)
|
173
|
+
method = request.method
|
174
|
+
end
|
169
175
|
if ENV['RAILS_RELATIVE_URL_ROOT']
|
170
176
|
url.gsub!(/^#{ENV['RAILS_RELATIVE_URL_ROOT']}/, "")
|
171
177
|
url.gsub!(/^https?:\/\/.*?#{ENV['RAILS_RELATIVE_URL_ROOT']}/, "")
|
172
178
|
end
|
173
|
-
Rails.application.routes.recognize_path(url)
|
179
|
+
Rails.application.routes.recognize_path(url, :method => method)
|
174
180
|
end
|
175
181
|
|
176
182
|
def url_for_page_path(options={})
|
data/hobo.gemspec
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency('shoulda', [">= 0"])
|
21
21
|
s.add_development_dependency('irt', ["= 1.2.11"])
|
22
22
|
s.add_development_dependency('mocha')
|
23
|
-
s.add_development_dependency('sqlite3')
|
24
23
|
s.add_development_dependency('yard')
|
25
24
|
|
26
25
|
s.executables = ["hobo"]
|
@@ -17,12 +17,16 @@ module Hobo
|
|
17
17
|
install_plugin_helper('hobo_rapid', nil, opts.merge(:skip_dryml => true, :skip_gem => true))
|
18
18
|
say "Installing hobo_jquery plugin..."
|
19
19
|
install_plugin_helper('hobo_jquery', nil, opts.merge(:skip_gem => true))
|
20
|
+
say "Installing #{opts[:theme]} theme..."
|
21
|
+
install_plugin_helper(opts[:theme], nil, opts)
|
20
22
|
say "Installing hobo_jquery_ui plugin..."
|
21
23
|
install_plugin_helper('hobo_jquery_ui', nil, opts)
|
24
|
+
if opts[:theme]=='hobo_bootstrap'
|
25
|
+
say "Installing hobo_bootstrap_ui plugin..."
|
26
|
+
install_plugin_helper('hobo_bootstrap_ui', nil, opts)
|
27
|
+
end
|
22
28
|
|
23
|
-
say "Installing #{opts[:theme]} theme..."
|
24
29
|
inject_css_require("jquery-ui/#{opts[:ui_theme]}", opts[:subsite], nil)
|
25
|
-
install_plugin_helper(opts[:theme], nil, opts)
|
26
30
|
|
27
31
|
unless opts[:skip_gem]
|
28
32
|
gem_with_comments("jquery-ui-themes", "~> 0.0.4")
|
@@ -9,7 +9,7 @@ module Generators
|
|
9
9
|
|
10
10
|
unless File.read("Gemfile") =~ /^gem ("|')#{name}/
|
11
11
|
if (comments = options.delete(:comments))
|
12
|
-
append_file "Gemfile", "#{comments}
|
12
|
+
append_file "Gemfile", "#{comments}", :verbose => false
|
13
13
|
end
|
14
14
|
|
15
15
|
gem(args[0], args[1], options)
|
@@ -26,7 +26,7 @@ module Hobo
|
|
26
26
|
:desc => "Front Controller Name", :default => 'front'
|
27
27
|
|
28
28
|
class_option :front_theme, :type => :string,
|
29
|
-
:desc => "Front Theme", :default => '
|
29
|
+
:desc => "Front Theme", :default => 'bootstrap'
|
30
30
|
|
31
31
|
class_option :front_ui_theme, :type => :string,
|
32
32
|
:desc => "Front jQuery-UI Theme", :default => 'redmond'
|
@@ -187,7 +187,7 @@ EOI
|
|
187
187
|
if wizard?
|
188
188
|
say_title 'Front Theme'
|
189
189
|
say "The currently available themes are clean, clean_admin, clean_sidemenu and bootstrap."
|
190
|
-
@front_theme = ask("Choose a theme for the front site: [<enter>=
|
190
|
+
@front_theme = ask("Choose a theme for the front site: [<enter>=bootstrap|<custom_name>]", 'bootstrap')
|
191
191
|
|
192
192
|
say_title 'Front jQuery-UI Theme'
|
193
193
|
say "The currently available jQuery-UI themes are listed here: https://github.com/fatdude/jquery-ui-themes-rails/blob/master/README.markdown"
|
data/lib/hobo/controller.rb
CHANGED
@@ -71,6 +71,10 @@ module Hobo
|
|
71
71
|
|
72
72
|
|
73
73
|
def ajax_update_response(render_specs, results={}, options={})
|
74
|
+
if render_specs.blank?
|
75
|
+
render :js => ''
|
76
|
+
return
|
77
|
+
end
|
74
78
|
controller, action = controller_action_from_page_path
|
75
79
|
identifier = view_context.view_paths.find( action,
|
76
80
|
controller,
|
@@ -379,6 +379,7 @@ module Hobo
|
|
379
379
|
if self.class.name == "#{controller.camelize}Controller" && action == "index"
|
380
380
|
params['action'] = 'index'
|
381
381
|
self.action_name = 'index'
|
382
|
+
self.this = find_or_paginate(model, {})
|
382
383
|
index
|
383
384
|
else
|
384
385
|
render :template => "#{controller}/#{action}"
|
@@ -68,7 +68,7 @@ module Hobo
|
|
68
68
|
flash[:error] = options[:failure_notice]
|
69
69
|
hobo_ajax_response if request.xhr? && !performed?
|
70
70
|
else
|
71
|
-
self.sign_user_in(user, options)
|
71
|
+
self.sign_user_in(user, options, &block)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -110,7 +110,7 @@ module Hobo
|
|
110
110
|
|
111
111
|
def hobo_forgot_password
|
112
112
|
if request.post?
|
113
|
-
user = model.find_by_email_address(params[:email_address])
|
113
|
+
user = model.find_by_email_address(params[:email_address].to_s)
|
114
114
|
if user && (!block_given? || yield(user))
|
115
115
|
user.lifecycle.request_password_reset!(:nobody)
|
116
116
|
end
|
@@ -166,7 +166,12 @@ module Hobo
|
|
166
166
|
old_user = current_user
|
167
167
|
self.current_user = user
|
168
168
|
|
169
|
-
|
169
|
+
if block_given?
|
170
|
+
unless yield
|
171
|
+
self.current_user = nil
|
172
|
+
return
|
173
|
+
end
|
174
|
+
end
|
170
175
|
|
171
176
|
if !user.account_active?
|
172
177
|
# account not activate - cancel this login
|
@@ -31,6 +31,8 @@ module Hobo
|
|
31
31
|
def create_scope(check_only=false)
|
32
32
|
matched_scope = true
|
33
33
|
|
34
|
+
like_operator = ActiveRecord::Base.connection.adapter_name =~ /postg/i ? 'ILIKE' : 'LIKE'
|
35
|
+
|
34
36
|
case
|
35
37
|
# --- Association Queries --- #
|
36
38
|
|
@@ -152,7 +154,7 @@ module Hobo
|
|
152
154
|
return true if check_only
|
153
155
|
|
154
156
|
def_scope do |str|
|
155
|
-
@klass.where "#{column_sql(col)}
|
157
|
+
@klass.where "#{column_sql(col)} #{like_operator} ?", "%#{str}%"
|
156
158
|
end
|
157
159
|
|
158
160
|
# name_does_not_contain
|
@@ -160,7 +162,7 @@ module Hobo
|
|
160
162
|
return true if check_only
|
161
163
|
|
162
164
|
def_scope do |str|
|
163
|
-
@klass.where "#{column_sql(col)} NOT
|
165
|
+
@klass.where "#{column_sql(col)} NOT #{like_operator} ?", "%#{str}%"
|
164
166
|
end
|
165
167
|
|
166
168
|
# name_starts(str)
|
@@ -168,7 +170,7 @@ module Hobo
|
|
168
170
|
return true if check_only
|
169
171
|
|
170
172
|
def_scope do |str|
|
171
|
-
@klass.where "#{column_sql(col)}
|
173
|
+
@klass.where "#{column_sql(col)} #{like_operator} ?", "#{str}%"
|
172
174
|
end
|
173
175
|
|
174
176
|
# name_does_not_start
|
@@ -176,7 +178,7 @@ module Hobo
|
|
176
178
|
return true if check_only
|
177
179
|
|
178
180
|
def_scope do |str|
|
179
|
-
@klass.where "#{column_sql(col)} NOT
|
181
|
+
@klass.where "#{column_sql(col)} NOT #{like_operator} ?", "#{str}%"
|
180
182
|
end
|
181
183
|
|
182
184
|
# name_ends(str)
|
@@ -184,7 +186,7 @@ module Hobo
|
|
184
186
|
return true if check_only
|
185
187
|
|
186
188
|
def_scope do |str|
|
187
|
-
@klass.where "#{column_sql(col)}
|
189
|
+
@klass.where "#{column_sql(col)} #{like_operator} ?", "%#{str}"
|
188
190
|
end
|
189
191
|
|
190
192
|
# name_does_not_end(str)
|
@@ -192,7 +194,7 @@ module Hobo
|
|
192
194
|
return true if check_only
|
193
195
|
|
194
196
|
def_scope do |str|
|
195
|
-
@klass.where "#{column_sql(col)} NOT
|
197
|
+
@klass.where "#{column_sql(col)} NOT #{like_operator} ?", "%#{str}"
|
196
198
|
end
|
197
199
|
|
198
200
|
# published (a boolean column)
|
@@ -62,8 +62,7 @@ Redirect to the URI stored by the most recent store_location call or to the pass
|
|
62
62
|
When called with before_filter, `login_from_cookie` will call `authenticated_user_from_cookie` to check for
|
63
63
|
an `auth_token` cookie, and if the result is appropiate, it will log the user in.
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
See the [controller section in Users and Authentication](/manual/users_and_authentication#hobo_user_controller) for more information
|
67
66
|
|
68
67
|
## create_auth_cookie
|
69
68
|
|
@@ -71,6 +70,9 @@ Populates `cookies[:auth_token]` with `current_user` data.
|
|
71
70
|
|
72
71
|
|
73
72
|
|
73
|
+
See also the [Hobo User Controller section](/manual/users_and_authentication#hobo_user_controller) in the Users and Authentication manual.
|
74
|
+
|
75
|
+
|
74
76
|
# Cache
|
75
77
|
|
76
78
|
## expire_swept_caches_for(obj, attr=nil)
|
@@ -84,6 +86,8 @@ Refer to the `<swept-cache>` taglib for more information.
|
|
84
86
|
|
85
87
|
## Introduction to the Hobo Model Controller Module
|
86
88
|
|
89
|
+
Adding `hobo_model_controller` to one of your controllers will include this module
|
90
|
+
|
87
91
|
This module uses `def included(base)` to run some code in the context of the current controller. Some interesting stuff:
|
88
92
|
* Defines @auto_actions as an empty hash if it's not already defined.
|
89
93
|
* Runs `extend ClassMethods` to add the ClassMethods module to the current controller.
|
@@ -91,33 +95,72 @@ This module uses `def included(base)` to run some code in the context of the cur
|
|
91
95
|
* Rescues from some errors: `ActiveRecord::RecordNotFound, ActiveRecord::RecordNotFound, Hobo::Model::Lifecycles::LifecycleKeyError`
|
92
96
|
* Loads some subsite magic
|
93
97
|
|
94
|
-
|
98
|
+
## Class Methods
|
95
99
|
|
96
100
|
|
97
|
-
|
101
|
+
### model_name and model
|
98
102
|
|
99
103
|
`model_name` returns `model.name.underscore`
|
100
104
|
|
101
105
|
`model` returns `@model` or `controller_name.camelcase.singularize.constantize`
|
102
106
|
|
103
107
|
|
104
|
-
|
108
|
+
### autocomplete
|
109
|
+
|
110
|
+
This is the action called by the `<name-one>` tag to autocomplete results. See [Autocompleters](/manual/controllers#autocompleters) section in the controller manual.
|
111
|
+
|
112
|
+
|
113
|
+
### web_method
|
114
|
+
|
115
|
+
See [Web methods](/manual/controllers#web_methods) in the Controller manual.
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
### auto_actions
|
120
|
+
|
121
|
+
See [Selecting the automatic actions](/manual/controllers#selecting_the_automatic_actions) in the Controller manual.
|
122
|
+
|
123
|
+
|
124
|
+
### def_lifecycle_actions
|
125
|
+
|
126
|
+
See [Lifecycles](/manual/controllers#lifecycles) in the Controller manual.
|
127
|
+
|
128
|
+
|
129
|
+
## Instance Methods
|
130
|
+
|
131
|
+
### find_instance
|
132
|
+
|
133
|
+
If your model is Foo, this method is equivalent to
|
134
|
+
|
135
|
+
Foo.find(params[:id])
|
136
|
+
|
137
|
+
in the simple case. However, it also understands owned routes and sets `acting_user`.
|
138
|
+
|
139
|
+
@foo = find_instance
|
140
|
+
|
141
|
+
is quite frequently the first line a custom Hobo controller action.
|
142
|
+
|
143
|
+
|
144
|
+
### re_render_form
|
105
145
|
|
106
|
-
|
146
|
+
If you have errors on your page, you can call this helper to re-render the view that contains the source form, with errors highlighted.
|
107
147
|
|
108
148
|
|
109
|
-
|
149
|
+
### destination_after_submit
|
110
150
|
|
111
|
-
|
151
|
+
Contains the logic for [Automatic Redirects](/manual/controllers#automatic_redirects).
|
112
152
|
|
113
153
|
|
154
|
+
### parse_sort_param
|
114
155
|
|
115
|
-
|
156
|
+
Converts params[:sort] from the form used by `<table-plus>` into a form suitable to be passed to the [order_by](/manual/scopes#order_by) scope.
|
116
157
|
|
117
|
-
|
158
|
+
Simple usage is to pass a list of field names, however the last parameter can be a hash which maps from field name to database column name.
|
118
159
|
|
160
|
+
parse_sort_param(:title, :isbn, :author => "authors.last_name")
|
119
161
|
|
162
|
+
`parse_sort_param` accepts dotted field names, automatically pluralizing to determine the database column.
|
120
163
|
|
121
|
-
|
164
|
+
Story.include(:tasks).order_by(parse_sort_param("task.title"))
|
122
165
|
|
123
|
-
|
166
|
+
will sort on `task.title` as long as :tasks is included or joined to the scope
|
@@ -28,7 +28,17 @@ Contents
|
|
28
28
|
|
29
29
|
Using multi-model forms in Hobo is very straightforward:
|
30
30
|
|
31
|
-
|
31
|
+
class Blog < ActiveRecord::Base
|
32
|
+
hobo_model
|
33
|
+
has_many :posts, :accessible => true, :inverse_of => :blog
|
34
|
+
|
35
|
+
class Post < ActiveRecord::Base
|
36
|
+
hobo_model
|
37
|
+
belongs_to :blog, :inverse_of => :posts
|
38
|
+
|
39
|
+
The `:accessible` flag is a Hobo addition, the `:inverse_of` flag is
|
40
|
+
standard Rails. `:inverse_of` is optional but highly recommended in
|
41
|
+
Rails; Hobo requires it.
|
32
42
|
|
33
43
|
Once you've done that, the default forms that Hobo builds will use the
|
34
44
|
[input-many](/api_tag_defs/input-many) tag.
|
@@ -243,8 +253,8 @@ large number of elements in the association.
|
|
243
253
|
|
244
254
|
Both mechanisms are compatible and may be enabled simultaneously.
|
245
255
|
|
246
|
-
It's certainly possible that Rapid
|
247
|
-
require `accept_nested_attributes_for`.
|
248
|
-
Hobo will drop support for accessible associations
|
249
|
-
itself changes significantly.
|
256
|
+
It's certainly possible that later versions of Rapid will acquire tags
|
257
|
+
that will require `accept_nested_attributes_for`. However, it's
|
258
|
+
unlikely that Hobo will drop support for accessible associations
|
259
|
+
unless ActiveRecord itself changes significantly.
|
250
260
|
|
@@ -1,10 +1,10 @@
|
|
1
|
+
Hobo Scopes
|
2
|
+
{: .document-title}
|
3
|
+
|
1
4
|
doctest: prepare testapp environment
|
2
5
|
doctest_require: '../prepare_testapp'
|
3
6
|
{.hidden}
|
4
7
|
|
5
|
-
Hobo Scopes
|
6
|
-
{: .document-title}
|
7
|
-
|
8
8
|
Hobo scopes are an extension of the *named scope* and *dynamic finder*
|
9
9
|
functionality introduced in Rails 2.1, 2.2 and 2.3.
|
10
10
|
|
@@ -75,8 +75,7 @@ Let's set up a few models for our testing:
|
|
75
75
|
Generate a migration and run it:
|
76
76
|
{.hidden}
|
77
77
|
|
78
|
-
>>
|
79
|
-
>> system("rails g hobo:migration < m.txt")
|
78
|
+
>> system("rails g hobo:migration -m -n")
|
80
79
|
>> ActionDispatch::Reloader.cleanup!
|
81
80
|
>> ActionDispatch::Reloader.prepare!
|
82
81
|
>> Person.connection.clear_cache!
|
@@ -135,21 +134,29 @@ But the Hobo scope form allows us to supply several variations
|
|
135
134
|
|
136
135
|
## \_contains
|
137
136
|
|
137
|
+
Case insensitive.
|
138
|
+
|
138
139
|
>> Person.name_contains("y").*.name
|
139
140
|
=> ["Bryan", "Bethany"]
|
140
141
|
|
141
142
|
## \_does\_not\_contain
|
142
143
|
|
143
|
-
|
144
|
+
Case insensitive.
|
145
|
+
|
146
|
+
>> Person.name_does_not_contain("b").*.name
|
144
147
|
=> []
|
145
148
|
|
146
149
|
## \_starts
|
147
150
|
|
148
|
-
|
151
|
+
Case insensitive.
|
152
|
+
|
153
|
+
>> Person.name_starts("b").*.name
|
149
154
|
=> ["Bryan", "Bethany"]
|
150
155
|
|
151
156
|
## \_does\_not\_start
|
152
157
|
|
158
|
+
Case insensitive.
|
159
|
+
|
153
160
|
>> Person.name_does_not_start("B").length
|
154
161
|
=> 0
|
155
162
|
|
metadata
CHANGED
@@ -1,183 +1,177 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: -182171504
|
5
5
|
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- pre
|
11
|
+
- 8
|
12
|
+
version: 2.0.0.pre8
|
6
13
|
platform: ruby
|
7
|
-
authors:
|
14
|
+
authors:
|
8
15
|
- Tom Locke
|
9
16
|
autorequire:
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
|
20
|
+
date: 2013-02-04 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
15
23
|
name: hobo_support
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - '='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.0.pre7
|
22
|
-
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
version: 2.0.0.pre7
|
27
|
+
requirements:
|
28
|
+
- - "="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: -182171504
|
31
|
+
segments:
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
- 0
|
35
|
+
- pre
|
36
|
+
- 8
|
37
|
+
version: 2.0.0.pre8
|
38
38
|
type: :runtime
|
39
|
+
version_requirements: *id001
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: hobo_fields
|
39
42
|
prerelease: false
|
40
|
-
|
43
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
44
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
version: 2.0.0.pre7
|
45
|
+
requirements:
|
46
|
+
- - "="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: -182171504
|
49
|
+
segments:
|
50
|
+
- 2
|
51
|
+
- 0
|
52
|
+
- 0
|
53
|
+
- pre
|
54
|
+
- 8
|
55
|
+
version: 2.0.0.pre8
|
54
56
|
type: :runtime
|
57
|
+
version_requirements: *id002
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: dryml
|
55
60
|
prerelease: false
|
56
|
-
|
61
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
62
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
version: 3.0.0
|
63
|
+
requirements:
|
64
|
+
- - "="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: -182171504
|
67
|
+
segments:
|
68
|
+
- 2
|
69
|
+
- 0
|
70
|
+
- 0
|
71
|
+
- pre
|
72
|
+
- 8
|
73
|
+
version: 2.0.0.pre8
|
70
74
|
type: :runtime
|
75
|
+
version_requirements: *id003
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: will_paginate
|
71
78
|
prerelease: false
|
72
|
-
|
79
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
80
|
none: false
|
74
|
-
requirements:
|
81
|
+
requirements:
|
75
82
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 7
|
85
|
+
segments:
|
86
|
+
- 3
|
87
|
+
- 0
|
88
|
+
- 0
|
77
89
|
version: 3.0.0
|
78
|
-
|
90
|
+
type: :runtime
|
91
|
+
version_requirements: *id004
|
92
|
+
- !ruby/object:Gem::Dependency
|
79
93
|
name: rubydoctest
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.1.3
|
86
|
-
type: :development
|
87
94
|
prerelease: false
|
88
|
-
|
95
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
96
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 21
|
101
|
+
segments:
|
102
|
+
- 1
|
103
|
+
- 1
|
104
|
+
- 3
|
93
105
|
version: 1.1.3
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: shoulda
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
106
|
type: :development
|
107
|
+
version_requirements: *id005
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
name: shoulda
|
103
110
|
prerelease: false
|
104
|
-
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: irt
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
111
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
113
112
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
118
120
|
type: :development
|
121
|
+
version_requirements: *id006
|
122
|
+
- !ruby/object:Gem::Dependency
|
123
|
+
name: irt
|
119
124
|
prerelease: false
|
120
|
-
|
125
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
126
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
127
|
+
requirements:
|
128
|
+
- - "="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 9
|
131
|
+
segments:
|
132
|
+
- 1
|
133
|
+
- 2
|
134
|
+
- 11
|
125
135
|
version: 1.2.11
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: mocha
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
136
|
type: :development
|
137
|
+
version_requirements: *id007
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: mocha
|
135
140
|
prerelease: false
|
136
|
-
|
141
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
137
142
|
none: false
|
138
|
-
requirements:
|
139
|
-
- -
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
150
|
type: :development
|
151
|
-
|
152
|
-
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
151
|
+
version_requirements: *id008
|
152
|
+
- !ruby/object:Gem::Dependency
|
159
153
|
name: yard
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
154
|
prerelease: false
|
168
|
-
|
155
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
169
156
|
none: false
|
170
|
-
requirements:
|
171
|
-
- -
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
type: :development
|
165
|
+
version_requirements: *id009
|
174
166
|
description: The web app builder for Rails
|
175
167
|
email: tom@tomlocke.com
|
176
|
-
executables:
|
168
|
+
executables:
|
177
169
|
- hobo
|
178
170
|
extensions: []
|
171
|
+
|
179
172
|
extra_rdoc_files: []
|
180
|
-
|
173
|
+
|
174
|
+
files:
|
181
175
|
- CHANGES-1.1.txt
|
182
176
|
- CHANGES-1.3.txt
|
183
177
|
- CHANGES-1.4.txt
|
@@ -383,28 +377,39 @@ files:
|
|
383
377
|
- test/permissions/test_permissions.rb
|
384
378
|
homepage: http://hobocentral.net
|
385
379
|
licenses: []
|
380
|
+
|
386
381
|
post_install_message:
|
387
|
-
rdoc_options:
|
382
|
+
rdoc_options:
|
388
383
|
- --charset=UTF-8
|
389
|
-
require_paths:
|
384
|
+
require_paths:
|
390
385
|
- lib
|
391
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
386
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
392
387
|
none: false
|
393
|
-
requirements:
|
394
|
-
- -
|
395
|
-
- !ruby/object:Gem::Version
|
396
|
-
|
397
|
-
|
388
|
+
requirements:
|
389
|
+
- - ">="
|
390
|
+
- !ruby/object:Gem::Version
|
391
|
+
hash: 3
|
392
|
+
segments:
|
393
|
+
- 0
|
394
|
+
version: "0"
|
395
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
398
396
|
none: false
|
399
|
-
requirements:
|
400
|
-
- -
|
401
|
-
- !ruby/object:Gem::Version
|
397
|
+
requirements:
|
398
|
+
- - ">="
|
399
|
+
- !ruby/object:Gem::Version
|
400
|
+
hash: 23
|
401
|
+
segments:
|
402
|
+
- 1
|
403
|
+
- 3
|
404
|
+
- 6
|
402
405
|
version: 1.3.6
|
403
406
|
requirements: []
|
407
|
+
|
404
408
|
rubyforge_project: hobo
|
405
|
-
rubygems_version: 1.8.
|
409
|
+
rubygems_version: 1.8.25
|
406
410
|
signing_key:
|
407
411
|
specification_version: 3
|
408
412
|
summary: The web app builder for Rails
|
409
413
|
test_files: []
|
414
|
+
|
410
415
|
has_rdoc:
|