hobo 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,46 @@ likely to cause conflicts, so it is highly recommended that you have
14
14
  your code backed up and in a change control system such as git or
15
15
  subversion.
16
16
 
17
+ === Hobo 1.0.3 ===
18
+
19
+ This is a security release. All applications that use the reset
20
+ password functionality or are on versions of Rails prior to version
21
+ 2.3.4 should upgrade.
22
+
23
+ To patch the reset password vulnerability, two changes have been made.
24
+
25
+ First of all, the lifecycle key hash mechanism has been changed.
26
+ Existing lifecycle keys will become invalid after you upgrade.
27
+ Lifecycle keys are typically short lived, so this is unlikely to be a
28
+ problem for most applications.
29
+
30
+ Secondly, lifecycle keys are now cleared on every transition to avoid
31
+ replay vulnerabilities. This new behaviour may be avoided by added
32
+ the `:keep_key => true` option to a transition.
33
+
34
+ More information about the vulnerability can be viewed on the [bug
35
+ report](https://hobo.lighthouseapp.com/projects/8324/tickets/666-user-model-secure-links-have-low-security).
36
+
37
+ Other changes:
38
+
39
+ The text input tag (`<textarea>`) has a security hole with versions of
40
+ Rails prior to 2.3.4. This release makes these old versions of Rails
41
+ safe again, although it is highly recommended that you upgrade to
42
+ Rails 2.3.11 because of other security vulnerabilities on earlier versions
43
+ of Rails.
44
+
45
+ The "include" automatic scope has been aliased to "includes" to
46
+ increase future compatibility with Rails 3. Future versions of Hobo
47
+ will remove support for "include".
48
+
49
+ This release increases compatibility with Ruby v1.9.2.
50
+
51
+ Hobo 1.0.2 introduced a major problem with chained scopes. This has
52
+ been fixed.
53
+
54
+ All code changes may viewed on the [github
55
+ log](https://github.com/tablatom/hobo/compare/v1.0.2...v1.0.3)
56
+
17
57
  === Hobo 1.0.2 ===
18
58
 
19
59
  This release is almost identical to 1.0.1 except that it updates the
data/Rakefile CHANGED
@@ -10,7 +10,11 @@ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/../hobosupport/
10
10
  require 'hobo'
11
11
 
12
12
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
13
- RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
13
+ if defined?(Bundler)
14
+ RUBYDOCTEST = 'bundle exec rubydoctest'
15
+ else
16
+ RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
17
+ end
14
18
 
15
19
  desc "Default Task"
16
20
  task :default => [ :test ]
@@ -66,6 +70,3 @@ Jeweler::Tasks.new do |gemspec|
66
70
  gemspec.files.include %w(tasks/environments.rake tasks/hobo_tasks.rake)
67
71
  end
68
72
  Jeweler::GemcutterTasks.new
69
- Jeweler::RubyforgeTasks.new do |rubyforge|
70
- rubyforge.doc_task = false
71
- end
@@ -95,6 +95,7 @@ Let's set up a few models for our testing:
95
95
  born_at :date
96
96
  code :integer
97
97
  male :boolean
98
+ foo :string
98
99
  timestamps
99
100
  end
100
101
 
@@ -119,19 +120,19 @@ Generate a migration and run it:
119
120
 
120
121
  >> ActiveRecord::Migration.class_eval(HoboFields::MigrationGenerator.run[0])
121
122
  >> Person.columns.*.name
122
- => ["id", "name", "born_at", "code", "male", "created_at", "updated_at", "state"]
123
+ => ["id", "name", "born_at", "code", "male", "foo", "created_at", "updated_at", "state"]
123
124
  {.hidden}
124
125
 
125
126
  And create a couple of fixtures:
126
127
 
127
128
  >>
128
129
  Bryan = Person.new(:name => "Bryan", :code => 17,
129
- :born_at => Date.new(1973,4,8), :male => true)
130
+ :born_at => Date.new(1973,4,8), :male => true, :foo => "common")
130
131
  >> Bryan.state = "active"
131
132
  >> Bryan.save!
132
133
  >>
133
134
  Bethany = Person.new(:name => "Bethany", :code => 42,
134
- :born_at => Date.new(1975,5,13), :male => false)
135
+ :born_at => Date.new(1975,5,13), :male => false, :foo => "common")
135
136
  >> Bethany.state = "inactive"
136
137
  >> Bethany.save!
137
138
  >> Friendship.new(:person => Bryan, :friend => Bethany).save!
@@ -287,12 +288,16 @@ Gives the N most recent items:
287
288
  >> Person.order_by(:code).*.name
288
289
  => ["Bryan", "Bethany"]
289
290
 
290
- ## include
291
+ ## includes
291
292
 
292
- Adding the include function to your query chain has the same effect as
293
+ Adding the includes function to your query chain has the same effect as
293
294
  the `:include` option to the `find` method.
294
295
 
295
- >> Person.include(:friends).*.name
296
+ >> Person.search("B", :name).include(:friends).*.name # test LH#839
297
+ => ["Bryan", "Bethany"]
298
+ .hidden
299
+
300
+ >> Person.includes(:friends).*.name
296
301
  => ["Bryan", "Bethany"]
297
302
 
298
303
  ## search
@@ -390,6 +395,15 @@ Like named scopes, Hobo scopes can be chained:
390
395
  >> Bryan.inactive_friends.inactive.*.name
391
396
  => ["Bethany"]
392
397
 
398
+ >> Person.scoped(:conditions => {:state => "active"}).scoped(:conditions => {:foo => "common"}).*.name
399
+ => ["Bryan"]
400
+
401
+ >> Person.with_friendship(Friendship.first).born_before(Date.new(1974)).*.name
402
+ => ["Bryan"]
403
+
404
+ >> Person.born_after(Date.new(1974)).with_friendship(Friendship.first).*.name
405
+ => []
406
+
393
407
  Clean up our test database:
394
408
  {.hidden}
395
409
 
@@ -165,7 +165,7 @@ end
165
165
  <% end -%>
166
166
  </header>
167
167
 
168
- <section param="content-body"<%= ' with-flash-messages' if aside_collections %>>
168
+ <section param="content-body">
169
169
  <% if main_content -%>
170
170
  <view:<%= main_content %> param="description"/>
171
171
  <% end -%>
@@ -0,0 +1,226 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{hobo}
8
+ s.version = "1.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tom Locke"]
12
+ s.date = %q{2011-02-25}
13
+ s.default_executable = %q{hobo}
14
+ s.email = %q{tom@tomlocke.com}
15
+ s.executables = ["hobo"]
16
+ s.extra_rdoc_files = [
17
+ "README"
18
+ ]
19
+ s.files = [
20
+ "CHANGES.txt",
21
+ "LICENSE.txt",
22
+ "README",
23
+ "Rakefile",
24
+ "bin/hobo",
25
+ "doctest/hobo/hobo_helper.rdoctest",
26
+ "doctest/hobo/lifecycles.rdoctest",
27
+ "doctest/model.rdoctest",
28
+ "doctest/multi_model_forms.rdoctest",
29
+ "doctest/scopes.rdoctest",
30
+ "dryml_generators/rapid/cards.dryml.erb",
31
+ "dryml_generators/rapid/forms.dryml.erb",
32
+ "dryml_generators/rapid/pages.dryml.erb",
33
+ "hobo.gemspec",
34
+ "lib/action_view_extensions/helpers/tag_helper.rb",
35
+ "lib/active_record/association_collection.rb",
36
+ "lib/active_record/association_proxy.rb",
37
+ "lib/active_record/association_reflection.rb",
38
+ "lib/active_record/viewhints_validations_interceptor.rb",
39
+ "lib/hobo.rb",
40
+ "lib/hobo/accessible_associations.rb",
41
+ "lib/hobo/authentication_support.rb",
42
+ "lib/hobo/controller.rb",
43
+ "lib/hobo/dev_controller.rb",
44
+ "lib/hobo/dryml.rb",
45
+ "lib/hobo/dryml/dryml_builder.rb",
46
+ "lib/hobo/dryml/dryml_doc.rb",
47
+ "lib/hobo/dryml/dryml_generator.rb",
48
+ "lib/hobo/dryml/dryml_support_controller.rb",
49
+ "lib/hobo/dryml/parser.rb",
50
+ "lib/hobo/dryml/parser/attribute.rb",
51
+ "lib/hobo/dryml/parser/base_parser.rb",
52
+ "lib/hobo/dryml/parser/document.rb",
53
+ "lib/hobo/dryml/parser/element.rb",
54
+ "lib/hobo/dryml/parser/elements.rb",
55
+ "lib/hobo/dryml/parser/source.rb",
56
+ "lib/hobo/dryml/parser/text.rb",
57
+ "lib/hobo/dryml/parser/tree_parser.rb",
58
+ "lib/hobo/dryml/part_context.rb",
59
+ "lib/hobo/dryml/scoped_variables.rb",
60
+ "lib/hobo/dryml/tag_parameters.rb",
61
+ "lib/hobo/dryml/taglib.rb",
62
+ "lib/hobo/dryml/template.rb",
63
+ "lib/hobo/dryml/template_environment.rb",
64
+ "lib/hobo/dryml/template_handler.rb",
65
+ "lib/hobo/find_for.rb",
66
+ "lib/hobo/generator.rb",
67
+ "lib/hobo/guest.rb",
68
+ "lib/hobo/hobo_helper.rb",
69
+ "lib/hobo/include_in_save.rb",
70
+ "lib/hobo/lifecycles.rb",
71
+ "lib/hobo/lifecycles/actions.rb",
72
+ "lib/hobo/lifecycles/creator.rb",
73
+ "lib/hobo/lifecycles/lifecycle.rb",
74
+ "lib/hobo/lifecycles/state.rb",
75
+ "lib/hobo/lifecycles/transition.rb",
76
+ "lib/hobo/model.rb",
77
+ "lib/hobo/model_controller.rb",
78
+ "lib/hobo/model_router.rb",
79
+ "lib/hobo/permissions.rb",
80
+ "lib/hobo/permissions/associations.rb",
81
+ "lib/hobo/rapid_helper.rb",
82
+ "lib/hobo/scopes.rb",
83
+ "lib/hobo/scopes/apply_scopes.rb",
84
+ "lib/hobo/scopes/association_proxy_extensions.rb",
85
+ "lib/hobo/scopes/automatic_scopes.rb",
86
+ "lib/hobo/scopes/named_scope_extensions.rb",
87
+ "lib/hobo/static_tags",
88
+ "lib/hobo/tasks/rails.rb",
89
+ "lib/hobo/translations.rb",
90
+ "lib/hobo/undefined.rb",
91
+ "lib/hobo/undefined_access_error.rb",
92
+ "lib/hobo/user.rb",
93
+ "lib/hobo/user_controller.rb",
94
+ "lib/hobo/view_hints.rb",
95
+ "rails/init.rb",
96
+ "rails_generators/hobo/USAGE",
97
+ "rails_generators/hobo/hobo_generator.rb",
98
+ "rails_generators/hobo/templates/application.css",
99
+ "rails_generators/hobo/templates/application.dryml",
100
+ "rails_generators/hobo/templates/dryml-support.js",
101
+ "rails_generators/hobo/templates/guest.rb",
102
+ "rails_generators/hobo/templates/initializer.rb",
103
+ "rails_generators/hobo_admin_site/USAGE",
104
+ "rails_generators/hobo_admin_site/hobo_admin_site_generator.rb",
105
+ "rails_generators/hobo_admin_site/templates/admin.css",
106
+ "rails_generators/hobo_admin_site/templates/application.dryml",
107
+ "rails_generators/hobo_admin_site/templates/controller.rb",
108
+ "rails_generators/hobo_admin_site/templates/site_taglib.dryml",
109
+ "rails_generators/hobo_admin_site/templates/users_index.dryml",
110
+ "rails_generators/hobo_front_controller/USAGE",
111
+ "rails_generators/hobo_front_controller/hobo_front_controller_generator.rb",
112
+ "rails_generators/hobo_front_controller/templates/controller.rb",
113
+ "rails_generators/hobo_front_controller/templates/functional_test.rb",
114
+ "rails_generators/hobo_front_controller/templates/helper.rb",
115
+ "rails_generators/hobo_front_controller/templates/index.dryml",
116
+ "rails_generators/hobo_front_controller/templates/summary.dryml",
117
+ "rails_generators/hobo_model/USAGE",
118
+ "rails_generators/hobo_model/hobo_model_generator.rb",
119
+ "rails_generators/hobo_model/templates/fixtures.yml",
120
+ "rails_generators/hobo_model/templates/hints.rb",
121
+ "rails_generators/hobo_model/templates/model.rb",
122
+ "rails_generators/hobo_model/templates/unit_test.rb",
123
+ "rails_generators/hobo_model_controller/USAGE",
124
+ "rails_generators/hobo_model_controller/hobo_model_controller_generator.rb",
125
+ "rails_generators/hobo_model_controller/templates/controller.rb",
126
+ "rails_generators/hobo_model_controller/templates/functional_test.rb",
127
+ "rails_generators/hobo_model_controller/templates/helper.rb",
128
+ "rails_generators/hobo_model_resource/USAGE",
129
+ "rails_generators/hobo_model_resource/hobo_model_resource_generator.rb",
130
+ "rails_generators/hobo_model_resource/templates/controller.rb",
131
+ "rails_generators/hobo_model_resource/templates/functional_test.rb",
132
+ "rails_generators/hobo_model_resource/templates/helper.rb",
133
+ "rails_generators/hobo_rapid/USAGE",
134
+ "rails_generators/hobo_rapid/hobo_rapid_generator.rb",
135
+ "rails_generators/hobo_rapid/templates/IE7.js",
136
+ "rails_generators/hobo_rapid/templates/blank.gif",
137
+ "rails_generators/hobo_rapid/templates/hobo-rapid.css",
138
+ "rails_generators/hobo_rapid/templates/hobo-rapid.js",
139
+ "rails_generators/hobo_rapid/templates/ie7-recalc.js",
140
+ "rails_generators/hobo_rapid/templates/lowpro.js",
141
+ "rails_generators/hobo_rapid/templates/reset.css",
142
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png",
143
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/30-3E547A-242E42.png",
144
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png",
145
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/300-ACD3E6-fff.png",
146
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/50-ACD3E6-fff.png",
147
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif",
148
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/pencil.png",
149
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/small_close.png",
150
+ "rails_generators/hobo_rapid/templates/themes/clean/public/images/spinner.gif",
151
+ "rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css",
152
+ "rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css",
153
+ "rails_generators/hobo_rapid/templates/themes/clean/views/clean.dryml",
154
+ "rails_generators/hobo_subsite/USAGE",
155
+ "rails_generators/hobo_subsite/hobo_subsite_generator.rb",
156
+ "rails_generators/hobo_subsite/templates/application.dryml",
157
+ "rails_generators/hobo_subsite/templates/controller.rb",
158
+ "rails_generators/hobo_subsite/templates/site_taglib.dryml",
159
+ "rails_generators/hobo_user_controller/USAGE",
160
+ "rails_generators/hobo_user_controller/hobo_user_controller_generator.rb",
161
+ "rails_generators/hobo_user_controller/templates/accept_invitation.dryml",
162
+ "rails_generators/hobo_user_controller/templates/controller.rb",
163
+ "rails_generators/hobo_user_controller/templates/functional_test.rb",
164
+ "rails_generators/hobo_user_controller/templates/helper.rb",
165
+ "rails_generators/hobo_user_model/USAGE",
166
+ "rails_generators/hobo_user_model/hobo_user_model_generator.rb",
167
+ "rails_generators/hobo_user_model/templates/fixtures.yml",
168
+ "rails_generators/hobo_user_model/templates/forgot_password.erb",
169
+ "rails_generators/hobo_user_model/templates/invite.erb",
170
+ "rails_generators/hobo_user_model/templates/mailer.rb",
171
+ "rails_generators/hobo_user_model/templates/model.rb",
172
+ "rails_generators/hobo_user_model/templates/unit_test.rb",
173
+ "script/destroy",
174
+ "script/generate",
175
+ "taglibs/core.dryml",
176
+ "taglibs/rapid.dryml",
177
+ "taglibs/rapid_core.dryml",
178
+ "taglibs/rapid_document_tags.dryml",
179
+ "taglibs/rapid_editing.dryml",
180
+ "taglibs/rapid_forms.dryml",
181
+ "taglibs/rapid_generics.dryml",
182
+ "taglibs/rapid_lifecycles.dryml",
183
+ "taglibs/rapid_navigation.dryml",
184
+ "taglibs/rapid_pages.dryml",
185
+ "taglibs/rapid_plus.dryml",
186
+ "taglibs/rapid_summary.dryml",
187
+ "taglibs/rapid_support.dryml",
188
+ "taglibs/rapid_translations.dryml",
189
+ "taglibs/rapid_user_pages.dryml",
190
+ "tasks/environments.rake",
191
+ "tasks/hobo_tasks.rake",
192
+ "test/generators/test_generator_helper.rb",
193
+ "test/generators/test_helper.rb",
194
+ "test/generators/test_hobo_model_controller_generator.rb",
195
+ "test/permissions/models/models.rb",
196
+ "test/permissions/models/schema.rb",
197
+ "test/permissions/test_permissions.rb"
198
+ ]
199
+ s.homepage = %q{http://hobocentral.net/}
200
+ s.require_paths = ["lib"]
201
+ s.rubyforge_project = %q{hobo}
202
+ s.rubygems_version = %q{1.4.2}
203
+ s.summary = %q{The web app builder for Rails}
204
+
205
+ if s.respond_to? :specification_version then
206
+ s.specification_version = 3
207
+
208
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
209
+ s.add_runtime_dependency(%q<rails>, [">= 2.2.2", "< 3.0.0"])
210
+ s.add_runtime_dependency(%q<will_paginate>, [">= 2.3.11", "~> 2"])
211
+ s.add_runtime_dependency(%q<hobosupport>, ["= 1.0.3"])
212
+ s.add_runtime_dependency(%q<hobofields>, ["= 1.0.3"])
213
+ else
214
+ s.add_dependency(%q<rails>, [">= 2.2.2", "< 3.0.0"])
215
+ s.add_dependency(%q<will_paginate>, [">= 2.3.11", "~> 2"])
216
+ s.add_dependency(%q<hobosupport>, ["= 1.0.3"])
217
+ s.add_dependency(%q<hobofields>, ["= 1.0.3"])
218
+ end
219
+ else
220
+ s.add_dependency(%q<rails>, [">= 2.2.2", "< 3.0.0"])
221
+ s.add_dependency(%q<will_paginate>, [">= 2.3.11", "~> 2"])
222
+ s.add_dependency(%q<hobosupport>, ["= 1.0.3"])
223
+ s.add_dependency(%q<hobofields>, ["= 1.0.3"])
224
+ end
225
+ end
226
+
@@ -25,19 +25,24 @@ module ActiveRecord
25
25
  record
26
26
  end
27
27
 
28
+ def member_class
29
+ proxy_reflection.klass
30
+ end
31
+
28
32
  # DO NOT call super here - AssociationProxy's version loads the collection, and that's bad.
29
33
  # TODO: this really belongs in Rails; migrate it there ASAP
30
34
  def respond_to?(*args)
31
- proxy_respond_to?(*args) || Array.new.respond_to?(*args)
35
+ return super if has_one_collection?
36
+ proxy_respond_to?(*args) || [].respond_to?(*args)
32
37
  end
33
38
 
34
- # TODO: send this patch into Rails. There's no reason to load the collection just to find out it acts like an array.
35
39
  def is_a?(klass)
36
- [].is_a?(klass)
37
- end
38
-
39
- def member_class
40
- proxy_reflection.klass
40
+ if has_one_collection?
41
+ load_target
42
+ @target.is_a?(klass)
43
+ else
44
+ [].is_a?(klass)
45
+ end
41
46
  end
42
47
 
43
48
  private
@@ -52,6 +57,10 @@ module ActiveRecord
52
57
  end
53
58
  end
54
59
 
60
+ def has_one_collection?
61
+ proxy_reflection.macro == :has_one
62
+ end
63
+
55
64
  end
56
65
  end
57
66
  end
@@ -21,8 +21,8 @@ class HoboError < RuntimeError; end
21
21
 
22
22
  module Hobo
23
23
 
24
- VERSION = "1.0.2"
25
-
24
+ VERSION = "1.0.3"
25
+
26
26
  class PermissionDeniedError < RuntimeError; end
27
27
 
28
28
  class RawJs < String; end
@@ -67,7 +67,7 @@ module Hobo
67
67
  accepts.xml do
68
68
  headers["Status"] = "Unauthorized"
69
69
  headers["WWW-Authenticate"] = %(Basic realm="Web Password")
70
- render :text => ht("hobo.messages.unauthenticated", :default=>["Couldn't authenticate you"], :status => '401 Unauthorized')
70
+ render :text => ht("hobo.messages.unauthenticated", :default=>["Couldn't authenticate you"]), :status => '401 Unauthorized'
71
71
  end
72
72
  end
73
73
  false
@@ -58,7 +58,7 @@ module Hobo
58
58
 
59
59
  def redirect_to_with_object_url(destination, *args)
60
60
  if destination.is_one_of?(String, Hash, Symbol)
61
- redirect_to_without_object_url(destination)
61
+ redirect_to_without_object_url(destination, *args)
62
62
  else
63
63
  redirect_to_without_object_url(object_url(destination, *args))
64
64
  end
@@ -123,7 +123,7 @@ module Hobo
123
123
  def restore_locals(locals)
124
124
  locals.map do |l|
125
125
  if l.is_a?(TypedId)
126
- Hobo::Model.find_by_typed_id(this_id)
126
+ Hobo::Model.find_by_typed_id(l)
127
127
  else
128
128
  l
129
129
  end
@@ -168,7 +168,6 @@ module Hobo
168
168
  def become(state_name, validate=true)
169
169
  state_name = state_name.to_sym
170
170
  record.write_attribute self.class.state_field, state_name.to_s
171
-
172
171
  if state_name == :destroy
173
172
  record.destroy
174
173
  true
@@ -210,7 +209,7 @@ module Hobo
210
209
  timestamp = record.read_attribute(key_timestamp_field)
211
210
  if timestamp
212
211
  timestamp = timestamp.getutc
213
- Digest::SHA1.hexdigest("#{record.id}-#{state_name}-#{timestamp}")
212
+ Digest::SHA1.hexdigest("#{record.id}-#{state_name}-#{timestamp}-#{ActionController::Base.session_options[:secret]}")
214
213
  end
215
214
  end
216
215
 
@@ -223,6 +222,10 @@ module Hobo
223
222
  provided_key && provided_key == key && !key_expired?
224
223
  end
225
224
 
225
+ def clear_key
226
+ record.write_attribute key_timestamp_field, nil
227
+ end
228
+
226
229
  def invariants_satisfied?
227
230
  self.class.invariants.all? { |i| record.instance_eval(&i) }
228
231
  end
@@ -34,7 +34,8 @@ module Hobo
34
34
 
35
35
 
36
36
  def change_state(record)
37
- record.lifecycle.become(get_state(record, end_state))
37
+ record.lifecycle.clear_key unless options[:new_key] || options[:keep_key]
38
+ return record.lifecycle.become(get_state(record, end_state))
38
39
  end
39
40
 
40
41
 
@@ -34,13 +34,17 @@ module Hobo
34
34
 
35
35
  alias_method_chain :has_one, :new_method
36
36
 
37
- def inherited(klass)
38
- super
39
- fields(false) do
40
- Hobo.register_model(klass)
41
- field(klass.inheritance_column, :string)
37
+ # eval avoids the ruby 1.9.2 "super from singleton method ..." error
38
+ # see LH#840
39
+ eval %(
40
+ def inherited(klass)
41
+ super
42
+ fields(false) do
43
+ Hobo.register_model(klass)
44
+ field(klass.inheritance_column, :string)
45
+ end
42
46
  end
43
- end
47
+ )
44
48
  end
45
49
 
46
50
  base.fields(false) # force hobofields to load
@@ -121,8 +125,12 @@ module Hobo
121
125
 
122
126
  ActiveRecord::Base.class_eval do
123
127
  def self.hobo_model
124
- include Hobo::Model
125
- fields(false) # force hobofields to load
128
+ if self.ancestors.include?(Hobo::Model)
129
+ Rails.logger.error "#{self}: Do not call hobo_model in derived classes."
130
+ else
131
+ include Hobo::Model
132
+ fields(false) # force hobofields to load
133
+ end
126
134
  end
127
135
  def self.hobo_user_model
128
136
  include Hobo::Model
@@ -521,7 +521,7 @@ module Hobo
521
521
  this.user_update_attributes(current_user, attributes)
522
522
  else
523
523
  self.this = new_for_create(attributes)
524
- this.save
524
+ this.user_save(current_user)
525
525
  end
526
526
  create_response(:new, options, &b)
527
527
  end
@@ -590,10 +590,11 @@ module Hobo
590
590
 
591
591
  self.this ||= args.first || find_instance
592
592
  changes = options[:attributes] || attribute_parameters or raise RuntimeError, ht(:"hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
593
- this.user_update_attributes(current_user, changes)
594
-
595
- # Ensure current_user isn't out of date
596
- @current_user = @this if @this == current_user
593
+
594
+ if this.user_update_attributes(current_user, changes)
595
+ # Ensure current_user isn't out of date
596
+ @current_user = @this if @this == current_user
597
+ end
597
598
 
598
599
  in_place_edit_field = changes.keys.first if changes.size == 1 && params[:render]
599
600
  update_response(in_place_edit_field, options, &b)
@@ -270,6 +270,11 @@ module Hobo
270
270
  { :include => inclusions }
271
271
  end
272
272
 
273
+ when "includes"
274
+ def_scope do |inclusions|
275
+ { :include => inclusions }
276
+ end
277
+
273
278
  when "search"
274
279
  def_scope do |query, *fields|
275
280
  words = query.split
@@ -1,27 +1,39 @@
1
1
  module ActiveRecord
2
2
  module NamedScope
3
- class Scope
4
-
5
- delegate :member_class, :to => :proxy_found
6
-
7
- include Hobo::Scopes::ApplyScopes
3
+
4
+ class Scope
5
+ delegate :member_class, :to => :proxy_found
6
+ include Hobo::Scopes::ApplyScopes
7
+ end
8
8
 
9
- def respond_to?(method, include_private=false)
10
- super || scopes.include?(method) || proxy_scope.respond_to?(method, include_private)
9
+ module ClassMethods
10
+ def scopes
11
+ hash = read_inheritable_attribute(:scopes)
12
+ if hash.nil?
13
+ if respond_to?(:create_automatic_scope)
14
+ write_inheritable_attribute(:scopes, new_automatic_scoping_hash(self))
15
+ else
16
+ # add a default_proc to optimize the next condition
17
+ write_inheritable_attribute(:scopes, Hash.new { |hash, key| nil })
18
+ end
19
+ elsif hash.default_proc.nil? && respond_to?(:create_automatic_scope)
20
+ write_inheritable_attribute(:scopes, new_automatic_scoping_hash(self).merge!(hash))
21
+ else
22
+ hash
23
+ end
11
24
  end
12
-
25
+
13
26
  private
14
-
15
- def method_missing(method, *args, &block)
16
- if scopes.include?(method)
17
- scopes[method].call(self, *args)
18
- else
19
- with_scope :find => proxy_options do
20
- proxy_scope.send(method, *args, &block)
27
+
28
+ def new_automatic_scoping_hash(o)
29
+ hash = Hash.new { |hash, key| o.create_automatic_scope(key) && hash[key] }
30
+ hash.meta_eval do
31
+ define_method :include? do |key, *args|
32
+ super(key, *args) || o.create_automatic_scope(key)
21
33
  end
22
34
  end
35
+ hash
23
36
  end
24
-
25
37
  end
26
38
  end
27
39
  end
@@ -635,7 +635,7 @@ new HoboBehavior("ul.input-many", {
635
635
  Event.stop(ev);
636
636
  var ul = el.up('ul.input-many'), li = el.up('li.input-many-li');
637
637
 
638
- if(li.id.search(/\[-1\]/ && ul.immediateDescendants().length>2)>=0) {
638
+ if(li.id.search(/\[-1\]/)>=0 && ul.immediateDescendants().length>2) {
639
639
  /* if(console) console.log("IE7 messed up again (bug 605)"); */
640
640
  return;
641
641
  }
@@ -51,7 +51,8 @@ executed at various points in the ajax request cycle:
51
51
  hiddens = case fields
52
52
  when '*', nil
53
53
  # TODO: Need a better (i.e. extensible) way to eleminate certain fields
54
- this.class.column_names - ['type', 'created_at', 'updated_at']
54
+ # marking a field as attr_protected is one way to eliminate a field
55
+ this.class.column_names - [this.class.inheritance_column, 'created_at', 'updated_at']
55
56
  else
56
57
  comma_split(fields)
57
58
  end
@@ -349,11 +350,12 @@ edit collections a `Category` model in your application:
349
350
  <def tag="collection-input" for="ActiveRecord::Base"><select-many merge/></def>
350
351
 
351
352
 
352
- <!-- A `<textarea>` input -->
353
+ <!-- A `<textarea>` input. Attributes are passed through to [text_area_tag](http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-text_area_tag). -->
353
354
  <def tag="input" for="text" attrs="name">
354
- <%= text_area_tag(name, this, attributes) %>
355
+ <%= text_area_tag(name, attributes["escape"]==false ? this : html_escape(this), attributes) %>
355
356
  </def>
356
357
 
358
+
357
359
  <!-- A checkbox plus a hidden-field. The hidden field trick comes from Rails - it means that when the checkbox is not checked, the parameter name is still submitted, with a '0' value (the value is '1' when the checkbox is checked) -->
358
360
  <def tag="input" for="boolean" attrs="name">
359
361
  <%= unless attributes[:disabled]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Locke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-12 00:00:00 -05:00
18
+ date: 2011-02-25 00:00:00 -05:00
19
19
  default_executable: hobo
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,12 +72,12 @@ dependencies:
72
72
  requirements:
73
73
  - - "="
74
74
  - !ruby/object:Gem::Version
75
- hash: 19
75
+ hash: 17
76
76
  segments:
77
77
  - 1
78
78
  - 0
79
- - 2
80
- version: 1.0.2
79
+ - 3
80
+ version: 1.0.3
81
81
  type: :runtime
82
82
  version_requirements: *id003
83
83
  - !ruby/object:Gem::Dependency
@@ -88,12 +88,12 @@ dependencies:
88
88
  requirements:
89
89
  - - "="
90
90
  - !ruby/object:Gem::Version
91
- hash: 19
91
+ hash: 17
92
92
  segments:
93
93
  - 1
94
94
  - 0
95
- - 2
96
- version: 1.0.2
95
+ - 3
96
+ version: 1.0.3
97
97
  type: :runtime
98
98
  version_requirements: *id004
99
99
  description:
@@ -102,8 +102,8 @@ executables:
102
102
  - hobo
103
103
  extensions: []
104
104
 
105
- extra_rdoc_files: []
106
-
105
+ extra_rdoc_files:
106
+ - README
107
107
  files:
108
108
  - CHANGES.txt
109
109
  - LICENSE.txt
@@ -118,6 +118,7 @@ files:
118
118
  - dryml_generators/rapid/cards.dryml.erb
119
119
  - dryml_generators/rapid/forms.dryml.erb
120
120
  - dryml_generators/rapid/pages.dryml.erb
121
+ - hobo.gemspec
121
122
  - lib/action_view_extensions/helpers/tag_helper.rb
122
123
  - lib/active_record/association_collection.rb
123
124
  - lib/active_record/association_proxy.rb
@@ -287,8 +288,8 @@ homepage: http://hobocentral.net/
287
288
  licenses: []
288
289
 
289
290
  post_install_message:
290
- rdoc_options:
291
- - --charset=UTF-8
291
+ rdoc_options: []
292
+
292
293
  require_paths:
293
294
  - lib
294
295
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -312,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
313
  requirements: []
313
314
 
314
315
  rubyforge_project: hobo
315
- rubygems_version: 1.3.7
316
+ rubygems_version: 1.4.2
316
317
  signing_key:
317
318
  specification_version: 3
318
319
  summary: The web app builder for Rails