Merge pull request #1109 from maco/seed_photos

add photos to seeds
This commit is contained in:
Daniel O'Connor
2016-12-04 10:30:07 +10:30
committed by GitHub
4 changed files with 20 additions and 2 deletions

View File

@@ -4,8 +4,9 @@ module Growstuff
PLANTING = { type: 'planting', class: 'Planting', relation: 'plantings' }.freeze
HARVEST = { type: 'harvest', class: 'Harvest', relation: 'harvests' }.freeze
GARDEN = { type: 'garden', class: 'Garden', relation: 'gardens' }.freeze
SEED = { type: 'seed', class: 'Seed', relation: 'seeds' }.freeze
ALL = [PLANTING, HARVEST, GARDEN].freeze
ALL = [PLANTING, HARVEST, GARDEN, SEED].freeze
def self.types
ALL.map do |model|

View File

@@ -1,5 +1,6 @@
class Seed < ActiveRecord::Base
extend FriendlyId
include PhotoCapable
friendly_id :seed_slug, use: [:slugged, :finders]
belongs_to :crop

View File

@@ -0,0 +1,9 @@
class AddPhotosSeedsTable < ActiveRecord::Migration
def change
create_table :photos_seeds, id: false do |t|
t.integer :photo_id
t.integer :seed_id
end
add_index(:photos_seeds, [:seed_id, :photo_id])
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161129021533) do
ActiveRecord::Schema.define(version: 20161201154922) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -373,6 +373,13 @@ ActiveRecord::Schema.define(version: 20161129021533) do
t.integer "planting_id"
end
create_table "photos_seeds", id: false, force: :cascade do |t|
t.integer "photo_id"
t.integer "seed_id"
end
add_index "photos_seeds", ["seed_id", "photo_id"], name: "index_photos_seeds_on_seed_id_and_photo_id", using: :btree
create_table "plant_parts", force: :cascade do |t|
t.string "name"
t.datetime "created_at"