Class: Administrate::Field::BelongsToSearch
- Inherits:
-
BelongsTo
- Object
- BelongsTo
- Administrate::Field::BelongsToSearch
- Defined in:
- lib/viniBaxter/spa/belongs_to_search.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
- #associated_class ⇒ Object
- #associated_resource_options ⇒ Object
- #associated_resource_options_short ⇒ Object
- #belong_to_scope_package(current_user, model) ⇒ Object
Instance Method Details
#associated_class ⇒ Object
14 15 16 |
# File 'lib/viniBaxter/spa/belongs_to_search.rb', line 14 def associated_class super end |
#associated_resource_options ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/viniBaxter/spa/belongs_to_search.rb', line 48 def puts candidate_resources puts candidate_resources.class [nil] + candidate_resources.map do |resource| puts resource puts resource.class [display_candidate_resource(resource), resource.send(primary_key)] end end |
#associated_resource_options_short ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/viniBaxter/spa/belongs_to_search.rb', line 58 def array = [] candidate_resources.each do |resource| array << resource.send(primary_key) end array end |
#belong_to_scope_package(current_user, model) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/viniBaxter/spa/belongs_to_search.rb', line 18 def belong_to_scope_package(current_user, model) # super # create a room need package reference # model is Package model_variable = model.to_s.underscore.pluralize # so we scope the current user packages # sed(...) t.ly/56cI scoped_model = current_user.send(model_variable).pluck(:id) # array = [] # puts "candidate_resources => #{candidate_resources}" # candidate_resources.each do |resource| # array << resource.send(primary_key) # end candidate_resources = Package.find(*scoped_model) final = Package.where(id: candidate_resources.map(&:id)) puts final puts final.class [nil] + final.map do |resource| puts resource puts resource.class [display_candidate_resource(resource), resource.send(primary_key)] end # array_key = array.keys # array_toto = array.pluck(:primary_key) # puts array_key # scoped_model.filter {|item| array.include?(item)} end |