Class: Project
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Project
- Defined in:
- app/models/project.rb
Class Method Summary collapse
-
.scope_by_dba_organization(dba_organization) ⇒ ActiveRecord::Relation
(also: scope_by_dba)
scope by dba organization.
-
.scope_by_party(party, options = {}) ⇒ ActiveRecord::Relation
scope by party.
Instance Method Summary collapse
Class Method Details
.scope_by_dba_organization(dba_organization) ⇒ ActiveRecord::Relation Also known as: scope_by_dba
scope by dba organization
22 23 24 |
# File 'app/models/project.rb', line 22 def scope_by_dba_organization(dba_organization) scope_by_party(dba_organization, {role_types: [RoleType.iid('dba_org')]}) end |
.scope_by_party(party, options = {}) ⇒ ActiveRecord::Relation
scope by party
or an array of Party ids
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/project.rb', line 36 def scope_by_party(party, ={}) table_alias = String.random statement = joins("inner join entity_party_roles as \"#{table_alias}\" on \"#{table_alias}\".entity_record_id = projects.id and \"#{table_alias}\".entity_record_type = 'Project'") .where("#{table_alias}.party_id" => party).uniq if [:role_types] statement = statement.where("#{table_alias}.role_type_id" => RoleType.find_child_role_types([:role_types])) end statement end |
Instance Method Details
#to_data_hash ⇒ Object
55 56 57 |
# File 'app/models/project.rb', line 55 def to_data_hash to_hash(only: [:id, :description, :created_at, :updated_at]) end |
#to_label ⇒ Object
51 52 53 |
# File 'app/models/project.rb', line 51 def to_label description end |