Ray
unread,Dec 2, 2008, 12:34:59 PM12/2/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Streamlined
Hi,
1. Select bypasses my scope code (around_filter) and fails.
(it displays ALL categories in the select dropdown rather than just
the scoped by tenant_id list.)
2. All my other Streamlined CRUD functions invoke my scope code and
work perfectly.
3. I also failed to get options_for_select to pass an arg to try to
scope the custom_options_method as a workaround.
3. Has anyone modified the core code to solve this and get select to
be filtered by the model scope code (around_filter)?
Ray - newbie
------------ my code extract below -------
Category has_many :products and Product belongs_to :category.
In products_ui
user_columns :id,
:tenant_id,
:product_code,
:category, {:show_view =>[:name, {:fields =>[:category_name]},],
:edit_view =>[:select, {:fields =>
[:category_name]},],},
...
In categories_controller.rb
#---------SCOPE CODE in controller ---------
around_filter :scope_by_tenant
def scope_by_tenant
Category.find_with_tenant_scope(current_user.tenant_id) { yield }
end
In category.rb (Model)
#---------SCOPE CODE IN MODEL see controller also ---
def self.find_with_tenant_scope(current_tenant_id)
with_scope(:find => { :conditions => ["categories.tenant_id = ?",
current_tenant_id] }) { yield }
end
Above scope code is bypassed by select and fails. Any suggestions?