PT: https://www.pivotaltracker.com/story/show/51457917
Maco found this. The problem was that if you had a blank planting date,
and then re-edited the planting, it would say "not yet set" in the form
field, then die when it later tried to convert that to a date.
I replaced Miles's planted_at_string stuff in the model with a simpler
parse_date method in the application helper.
It seems this interacts badly with the default_scope on postgres (but
not on sqlite3). Error message from the logs:
2013-06-01T02:21:05.312099+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
2013-06-01T02:21:05.312099+00:00 app[web.1]: LINE 1: ...photo_id" = 2 AND "plantings"."id" = 181 ORDER BY created_at...
2013-06-01T02:21:05.312099+00:00 app[web.1]: app/controllers/photos_controller.rb:59:in `create'
2013-06-01T02:21:05.312099+00:00 app[web.1]: ^
2013-06-01T02:21:05.312099+00:00 app[web.1]: : SELECT DISTINCT 1 AS one FROM "plantings" INNER JOIN "photos_plantings" ON "plantings"."id" = "photos_plantings"."planting_id" WHERE "photos_plantings"."photo_id" = 2 AND "plantings"."id" = 181 ORDER BY created_at desc LIMIT 1):
For now, we'll just have to rely on the controller (which adds the
association) to keep things unique.
Strictly speaking this doesn't prevent you adding them if you really
try, but the validation for that was beyond what I could figure out (the
docs don't help, and all SO/blog posts are outdated and didn't
work).
However, if you do somehow manage to add dups, you will never see them
again thanks to the :uniq => true in the model. That's good enough for
me.
now if you choose to pay 33.33 it doesn't round to 33.00
also removed PUT and DELETE actions from order items
(we don't want them for now, can reinstate later if/when we do.)
This works fine in reality, but we can't figure out how to write tests
for it. For some reason the @member object, which passes a test for
is_paid?, doesn't get recognised as such when it's passed through to the
view itself. Help?