I set up a new Rails application by following these instructions. I generated a new controller and added resources :tickets
to the routes file.
Hexapoda::Application.routes.draw do
resources :tickets
end
This is the controller (`/app/controllers/tickets_controller.rb').
class TicketsController < ApplicationController
def index
@tickets = Ticket.all
end
end
I then added a new model Ticket
in /app/models/ticket.rb
.
class Ticket
include MongoMapper::Document
key :summary, String, :required => true
end
Here's the view (/app/views/index.html.erb
):
<h1>Tickets#index</h1>
<p>Find me in app/views/tickets/index.html.erb</p>
Now when I go to /tickets
in my browser, I get an error message.
NoMethodError in TicketsController#index
undefined method `key?' for nil:NilClass
I have no idea what's going on. What could be the problem? I'm using Rails 3.2.5 and MongoMapper 0.11.1.
You need the latest MonoMapper from Master:
gem 'mongo_mapper', github: "jnunemaker/mongomapper"
And run bundle
Explanation: Rails 3.2.4 added a accessible_attributes method to ActiveModel, but MongoMapper already had this; so they were clobbering each other.
MM issue: Issue 419
MM commit that fixes: 4d35c67
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With