aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential.rb
blob: a329bf950be5d5a4706ff021d65bae333e45f999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Referential < ActiveRecord::Base
  validates_presence_of :name 
  validates_presence_of :slug

  before_create :create_schema 
  before_destroy :destroy_schema

  def lines
    Chouette::Line.all
  end

  def networks
    Chouette::Network.all
  end

  def companies
    Chouette::Company.all
  end

  private 

  def create_schema
    Apartment::Database.create self.slug
  end

  def destroy_schema
    Apartment::Database.drop self.slug
  end
  
end