I have been trying to build a backend admin , as written in Iain Hecker's tutorial: http://iain.nl/backends-in-rails-3-1 and I am trying to adapt it to Mongoid.
module Backend::ResourceHelper
def attributes
resource_class.attribute_names - %w(id created_at updated_at)
end
end
With the above code, I was getting the following error:
undefined method `attribute_names' for Backend::User:Class
So, I tried the solution pointed out in this post: How can I get all field names of the Mongoid Document?
I tried using 'resource_class.fields.keys' instead of 'resource_class.attribute_names' but I end up with the following error:
Showing app/views/backend/resource/_index.html.haml where line #9
raised:undefined method `id' for [:where, {}]:Array
Extracted source (around line #9):
6: %th
7: %tbody
8: - collection.each do |resource|
9: %tr[resource]
10: - attributes.each do |attr|
11: %td= resource.public_send(attr).to_s.truncate(20)
12: %td
I am new to Rails and I would really appreciate it if you could provide me some pointers..