On Tue, May 18, 2010 at 11:02 AM, Mark Jones <[email protected]> wrote:
> I have the following in my model:
>
> belongs_to :tester, :class_name => "User", :conditions =>
> {:administrator => true}
>
> and this correctly limits the drop down list of 'tester' in the edit
> page to just administrators however I wanted in place editing of this
> tester within the show page, so in my show.dryml I have:
>
> <% if current_user.administrator? -%>
> <field-list: fields="status, tester" tag="editor" />
> <% else %>
> <field-list: fields="status"/>
> <% end -%>
>
> and in this scenario this lists all Users, ignoring the condition of
> 'tester', do I also have to apply a condition to this editor tag, if
> so how do I do this I can't find any examples?

This is a current limitation of the editor tag - you could either swap
it out in the field list and explicitly pass the required options, OR
here's a patch that should (theoretically - not tested) make the
editor tag obey the :conditions set on the association:

change line 98 of rapid_editing.dryml from:
  options ||= this_field_reflection.klass.find(:all).select {|x|
can_view?(x)}.map {|x|

to

  options ||= this_field_reflection.klass.scoped(:conditions =>
this.conditions).find(:all).select {|x| can_view?(x)}.map {|x|

(above is one line, in case it wraps. This will pull the conditions
directly from the AssociationProxy and scope the search to them.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to