Skip to content

Instantly share code, notes, and snippets.

@soilforlifeforms
Created July 5, 2015 21:50
Show Gist options
  • Save soilforlifeforms/614fa4beb0f4b795c669 to your computer and use it in GitHub Desktop.
Save soilforlifeforms/614fa4beb0f4b795c669 to your computer and use it in GitHub Desktop.
class FollowUpVisit <ActiveRecord::Base
belongs_to :gardener
has_one :follow_up_visit_eating
has_one :follow_up_visit_garden
has_one :follow_up_visit_impression
has_one :follow_up_visit_selling
end
class FollowUpVisitEating <ActiveRecord::Base
belongs_to :follow_up_visit
end
class FollowUpVisitGarden <ActiveRecord::Base
belongs_to :follow_up_visit
end
:094 > f = FollowUpVisit.last
FollowUpVisit Load (1.5ms) SELECT "follow_up_visits".* FROM "follow_up_visits" ORDER BY "follow_up_visits"."id" DESC LIMIT 1
FollowUpVisit Load (1.5ms) SELECT "follow_up_visits".* FROM "follow_up_visits" ORDER BY "follow_up_visits"."id" DESC LIMIT 1
=> #<FollowUpVisit id: 19, created_at: "2015-07-05 21:47:36", updated_at: "2015-07-05 21:47:36", gardener_id: 2>
2.1.2 :095 > f.follow_up_visit_garden
FollowUpVisitGarden Load (1.1ms) SELECT "follow_up_visit_gardens".* FROM "follow_up_visit_gardens" WHERE "follow_up_visit_gardens"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
FollowUpVisitGarden Load (1.1ms) SELECT "follow_up_visit_gardens".* FROM "follow_up_visit_gardens" WHERE "follow_up_visit_gardens"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
=> nil
2.1.2 :096 > f.follow_up_visit_impression
FollowUpVisitImpression Load (0.3ms) SELECT "follow_up_visit_impressions".* FROM "follow_up_visit_impressions" WHERE "follow_up_visit_impressions"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
FollowUpVisitImpression Load (0.3ms) SELECT "follow_up_visit_impressions".* FROM "follow_up_visit_impressions" WHERE "follow_up_visit_impressions"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
=> nil
2.1.2 :097 > f.follow_up_visit_selling
FollowUpVisitSelling Load (43.6ms) SELECT "follow_up_visit_sellings".* FROM "follow_up_visit_sellings" WHERE "follow_up_visit_sellings"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
FollowUpVisitSelling Load (43.6ms) SELECT "follow_up_visit_sellings".* FROM "follow_up_visit_sellings" WHERE "follow_up_visit_sellings"."follow_up_visit_id" = $1 LIMIT 1 [["follow_up_visit_id", 19]]
=> nil
2.1.2 :098 > f.follow_up_visit_eating
PG::UndefinedColumn: ERROR: column follow_up_visit_eatings.follow_up_visit_id does not exist
LINE 1: ..._eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up...
^
: SELECT "follow_up_visit_eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up_visit_eatings"."follow_up_visit_id" = $1 LIMIT 1
PG::UndefinedColumn: ERROR: column follow_up_visit_eatings.follow_up_visit_id does not exist
LINE 1: ..._eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up...
^
: SELECT "follow_up_visit_eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up_visit_eatings"."follow_up_visit_id" = $1 LIMIT 1
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column follow_up_visit_eatings.follow_up_visit_id does not exist
LINE 1: ..._eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up...
^
: SELECT "follow_up_visit_eatings".* FROM "follow_up_visit_eatings" WHERE "follow_up_visit_eatings"."follow_up_visit_id" = $1 LIMIT 1
create_table "follow_up_visit_eatings", force: true do |t|
t.integer "gardener_id"
t.integer "eating_sum"
t.string "veg_type_eaten"
t.boolean "eating"
t.integer "folow_up_visit_id"
end
create_table "follow_up_visit_gardens", force: true do |t|
t.integer "gardener_id"
t.boolean "still_gardening"
t.string "rating"
t.boolean "mini_nursery"
t.boolean "compost_heap"
t.boolean "trench_bed"
t.integer "trench_bed_sum"
t.boolean "container_garden"
t.integer "container_garden_sum"
t.boolean "other"
t.string "other_qualitative"
t.date "date_created"
t.integer "follow_up_visit_id"
end
create_table "follow_up_visit_impressions", force: true do |t|
t.integer "gardener_id"
t.string "future_plan"
t.text "issue"
t.text "positive"
t.text "negative"
t.text "general_comment"
t.integer "follow_up_visit_id"
end
create_table "follow_up_visit_sellings", force: true do |t|
t.integer "gardener_id"
t.boolean "selling"
t.string "selling_what"
t.string "selling_amount"
t.integer "follow_up_visit_id"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment