ソースを参照

Associate polls with elections and districts

tags/last-sinatra-version
Adrian Short 12年前
コミット
537dbcb6af
1個のファイルの変更5行の追加0行の削除
  1. +5
    -0
      models.rb

+ 5
- 0
models.rb ファイルの表示

@@ -12,6 +12,9 @@ class Poll
def turnout_percent def turnout_percent
@ballot_papers_issued.to_f / @electorate.to_f * 100.0 @ballot_papers_issued.to_f / @electorate.to_f * 100.0
end end

belongs_to :election
belongs_to :district
end end


class Postcode class Postcode
@@ -114,6 +117,7 @@ class Election
property :kind, String, :length => 255 property :kind, String, :length => 255
has n, :candidacies has n, :candidacies
has n, :polls
belongs_to :body belongs_to :body
def self.past def self.past
@@ -138,6 +142,7 @@ class District


belongs_to :body belongs_to :body
has n, :postcodes, :child_key => [:ward_id] has n, :postcodes, :child_key => [:ward_id]
has n, :polls
def self.slugify(name) def self.slugify(name)
name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase


読み込み中…
キャンセル
保存