Reputation: 1777
I created a new page with Active Admin. It currently just shows a table which lists all entries of the model "HotelRoom" for the current date.
Now I want to add a form where I can choose the Date for the data displayed in the table. But I can't get my head around how to add the form.
Forms usually look like this:
<% form_for @hotel_rooms do |f| %>
<p>
<%= f.label :date %><br />
<%= f.text_field :date %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
and then I want to add a datepicker to the textfield like described here http://railscasts.com/episodes/213-calendars But I always get the error:
undefined method `model_name' for NilClass:Class
What am I doing wrong?
EDIT: I tried adding the variable to the controller like this in the custom page file
controller do
def index
@hotel_rooms = HotelRoom.all
end
end
but still no luck. Same error.
Upvotes: 0
Views: 2077
Reputation: 1452
As usual - you have your @hotel_rooms variable not set in Controller at all ( or item with provided conditions was not found in DB ).
Update:
Otherwise - try to use:
form_for :hotel_room ...
Upvotes: 1