Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

let enum select options use instance method #44

Closed
leomao10 opened this Issue · 0 comments

2 participants

@leomao10

I just create a report class like this:

  class ContactReport 
    include Datagrid

    datagrid_attribute :current_user
    datagrid_attribute :sites

    def initialize(current_user, attributes = {})
      super(attributes)
      self.current_user = current_user
      if current_user
        self.sites      = current_user.sites.active.doing_jsa
        scope do
          PsmContact.index_scope.restricted(sites).includes(:user)
        end
      end
    end
  end

and now I want to add a enum filter, and its select item should be current_user.sites

    filter(:site_id, :enum, :select => lambda { current_user.sites.flatten }, :prompt => "All sites") do |value|
      where(:site_id => value)
    end

However, I could not do that because the context for the lambda is ContactReport and it do not have a current_user methods.

Could be helpful if you can enable the select option to use current instance's method

@bogdan bogdan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.