this_parent, this_field set incorrectly on new_for_owner page
Reported by Bryan Larsen | December 22nd, 2011 @ 02:01 AM
On a new_for_owner page, this_parent and this_field are
incorrectly set. this_parent is set to the owner, and this_field is
set to the attribute. But if you actually call
this_parent.send(this_field)
it returns an array
rather than an instance.
In consequence, if you do Ajax on the page, it uses "User:6:projects" to serialize the context rather than page_this as expected.
Comments and changes to this ticket
-
Bryan Larsen December 22nd, 2011 @ 02:06 AM
Here's the 2 proposed fixes for dryml/template_environment.rb
def new_object_context(new_this) new_context do if new_this.respond_to?(:origin) refl = (new_this.origin && new_this.origin_attribute.is_a?(Symbol) && new_this.origin.class.respond_to?(:reflections) && new_this.origin.class.reflections[new_this.origin_attribute]) if refl.nil? || refl.macro==:belongs_to || refl.macro==:has_one @_this_parent, @_this_field = new_this.origin, new_this.origin_attribute else # See bug [#989](/projects/8324/tickets/989 "Ticket #989") for more discussion. The commented out # section is more 'correct', but it is expensive and since # nobody really ran into this before, setting to nil seems # more appropriate. @_this_parent, @_this_field = nil, nil #@_this_parent = new_this.origin.send(new_this.origin_attribute) #@_this_field = @_this_parent.index(new_this) || @_this_parent.length end else @_this_parent, @_this_field = [nil, nil] end @_this = new_this # We might have lost track of where 'this' is relative to the form_this # check if this or this_parent are objects we've seen before in this form @_form_field_path = find_form_field_path(new_this) if @_form_field_path yield end end
-
Bryan Larsen December 22nd, 2011 @ 02:10 AM
(from [5c6e000a202870e29149e208e117550f32bb8054]) [#989] this_parent, this_field set incorrectly on new_for_owner page https://github.com/tablatom/hobo/commit/5c6e000a202870e29149e208e11...
-
Bryan Larsen January 16th, 2012 @ 04:04 PM
(from [80236822dd14bb04f41ef818c57d41f53ca7b633]) [#989] [#995] count tag broken on index_for_owner pages https://github.com/tablatom/hobo/commit/80236822dd14bb04f41ef818c57...
-
Bryan Larsen January 28th, 2012 @ 09:39 PM
(from [e4a1bee1f8130a2520799d34ccb202b490de0e7e]) [#989] [#995] count tag broken on index_for_owner pages https://github.com/tablatom/hobo/commit/e4a1bee1f8130a2520799d34ccb...
-
Bryan Larsen February 2nd, 2012 @ 06:34 PM
(from [ff95cac41deab19124661f23f7e25b22913e49a7]) [#989] [#995] count tag broken on index_for_owner pages https://github.com/tablatom/hobo/commit/ff95cac41deab19124661f23f7e...
-
Bryan Larsen September 4th, 2012 @ 04:25 PM
- State changed from new to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Referenced by
- 995 apply_scopes and paginate lose origin & origin_attribute (from [80236822dd14bb04f41ef818c57d41f53ca7b633]) [#989] ...
- 995 apply_scopes and paginate lose origin & origin_attribute (from [e4a1bee1f8130a2520799d34ccb202b490de0e7e]) [#989]...
- 995 apply_scopes and paginate lose origin & origin_attribute (from [ff95cac41deab19124661f23f7e25b22913e49a7]) [#989]...