Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added exhibitions
- Loading branch information
Barry Hoggard
committed
Jul 26, 2015
1 parent
89bc7c5
commit 7354575
Showing
13 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Artist < ActiveRecord::Base | ||
belongs_to :nationality | ||
has_many :works, dependent: :destroy | ||
validates :name, :sort_name, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Exhibition < ActiveRecord::Base | ||
validates :title, presence: true | ||
has_many :exhibition_works | ||
has_many :works, -> { order "exhibition_works.position" }, | ||
through: :exhibition_works, dependent: :destroy | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class ExhibitionWork < ActiveRecord::Base | ||
include RankedModel | ||
belongs_to :exhibition | ||
belongs_to :work | ||
ranks :position, with_same: :exhibition_id | ||
|
||
validates :exhibition_id, :work_id, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class Nationality < ActiveRecord::Base | ||
has_many :artists | ||
validates :name, presence: true, uniqueness: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class CreateExhibitions < ActiveRecord::Migration | ||
def change | ||
create_table :exhibitions do |t| | ||
t.string :title | ||
t.text :description | ||
t.date :start_date | ||
t.date :end_date | ||
t.timestamps null: false | ||
end | ||
|
||
add_index :exhibitions, :start_date | ||
add_index :exhibitions, :end_date | ||
|
||
create_table :exhibition_works, id: false do |t| | ||
t.references :exhibition, index: true, foreign_key: true, null: false | ||
t.references :work, index: true, foreign_key: true, null: false | ||
t.integer :position, null: false | ||
end | ||
add_index :exhibition_works, [:exhibition_id, :work_id], unique: true | ||
add_index :exhibition_works, :position, unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
englishkills: | ||
title: Selections from the Hoggard Wagner Collection at English Kills Art Gallery | ||
description: English Kills Art Gallery has installed a few dozen works from the Hoggard Wagner Art Collection in an exhibition which opens with a reception this Friday, September 21, 2012 from 7 to 10 pm. | ||
start_date: 2012-09-21 | ||
end_date: 2012-10-28 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class ExhibitionTest < ActiveSupport::TestCase | ||
test "validity" do | ||
assert exhibitions(:englishkills).valid? | ||
end | ||
end |