I found a gazillion answers for my issue if I was using Mongo, but none of th开发者_如何学Goe ones I see work out here since I am not using mongo.
Basically I have a report_controller.rb that has a very simple method defined:
def donations_by_season
@donations = Donation
end
and a very simple report/donations_by_season.html.erb as follows:
<%= form_for @donations do |f| %>
Stuff Will go here... such as fields to select a date for the season we wish to view.
<% end %>
There is no report model, just a controller and views.
But when I attempt to view /reports/donations_by_season I immediately get:
undefined method
to_key' for #<Class:0x00000114d85918>
What should I do to fix that? Am I doing my form incorrectly since there is no model associated with reports?
You should never be assigning an instance variable to point to a class object like this. You probably want this:
def donations_by_season
@donations = Donation.all
end
Note the .all
versus just leaving it blank. You could also do .new
or a litany of other methods, depending on what you're trying to do.
精彩评论