Commit b6f1f401 authored by AlanPCS's avatar AlanPCS

Hotfix: Add create model and add active field to citizens_service_places and...

Hotfix: Add create model and add active field to citizens_service_places and service_types_service_places tables
Signed-off-by: default avatarAlanPCS <apcs11@inf.ufpr.br>
parent 7e9fdd24
......@@ -185,9 +185,10 @@ class Citizen < ActiveRecord::Base
##############################
# Associações #
##############################
has_many :citizens_service_places
has_many :service_places, through: :citizens_service_places
has_many :blockings
has_many :schedules
has_many :service_places, join_table: :citizens_service_places
has_one :professional
has_one :dependant
has_one :citizen
......
class CitizenServicePlace < ActiveRecord::Base
belongs_to :citizen
belongs_to :service_place
end
......@@ -46,7 +46,7 @@ class ServiceType < ActiveRecord::Base
# Associações #
##############################
has_many :service_types_service_places
has_and_belongs_to_many :service_places, :join_table => "service_types_service_places"
has_many :service_places, :through => "service_types_service_places"
has_many :shifts
belongs_to :sector
......
class ServiceTypeServicePlace < ActiveRecord::Base
belongs_to :service_type
belongs_to :service_place
end
class CreateJoinTableServiceTypesServicePlaces < ActiveRecord::Migration
def change
create_table :service_types_service_places, id: false do |t|
t.integer :service_type_id
t.integer :service_place_id
t.index([:service_type_id, :service_place_id], unique: true, name: 'types_by_service_places')
t.index([:service_place_id, :service_type_id], unique: true, name: 'places_by_service_types')
end
end
end
class CreateJoinTableCitizensServicePlaces < ActiveRecord::Migration
def change
create_join_table :citizens, :service_places do |t|
t.index([:citizen_id, :service_place_id], unique: true, name: 'citizens_by_service_place')
t.index([:service_place_id, :citizen_id], unique: true, name: 'service_places_by_citizen')
end
end
end
class CreateCitizensServicePlaces < ActiveRecord::Migration
def change
create_table :citizens_service_places do |t|
t.references :citizen, index: true
t.references :service_place, index: true
t.boolean :active, default: true
t.timestamps
end
end
end
class CreateServiceTypesServicePlaces < ActiveRecord::Migration
def change
create_table :service_types_service_places do |t|
t.references :service_type, index: true
t.references :service_place, index: true
t.boolean :active, default: true
t.timestamps
end
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
citizen_id:
service_place_id:
active: false
two:
citizen_id:
service_place_id:
active: false
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
service_type_id:
service_place_id:
active: false
two:
service_type_id:
service_place_id:
active: false
require 'test_helper'
class CitizenServicePlaceTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class ServiceTypeServicePlaceTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment