I'm stumped with form_for(). I've RTFM'd until my eyeballs have bled.
I've looked over examples. I still don't get it, and each thing I try
leads to some other error. If someone can lead me to form_for
enlightenment, I'd be in your debt.
I'm using RESTful, shallow routing: one User :has_many Reports.
A Report has three fields of importance:
-- user_id (its parent)
-- location_id (reference to a Location record)
-- report_type ("graph" or "chart")
I'm trying to write a _report.html.erb partial that does double duty: it
can fill in fields of a new report (report.new_record? => true) as well
as update fields of an existing report (report.new_record? => false).
The _report partial receives two inputs: report is the current report
(either new or extant), and @user is set to the owning user.
The form_for needs present the user with [location_id] and [report_type]
fields (eventually to be replaced by pull_down lists), and needs to
silently fill in the [user_id] field of the report. Then, upon
form.submit(), it needs to 'POST user_reports_path(@user.id)' for new a
report, or 'PUT report_path(report.id)' for updating a report.
But even my basic attempts get an error message, and I'm not sure why: