3

I am just trying out Mongodb and the latest rails setup.

I am using Rails 4.0.0.beta 1, Ruby 2.0.0p0 and mongoid 4.0.0.

I have a problem: I can create and delete objects as expected but cannot update objects. No error is returned, and the development log shows the changed parameters are being passed correctly.

Has anyone else hit this issue?

2 Answers2

1

Digging deeper I see that mongoid 4.0.0 is still referencing moped 1.4.5, which officially only supports ruby versions upto 1.9.3.

The latest version of moped on github is 2.0.0, which works with ruby 2.0.0, but not yet published to the gem repositories.

Looks like I may have to wait for a while to try this combination.

1

I've been able to perform CRUD operations - however right now in my controllers (just for testing/spike) I'm allowing all parameters through strong_parameters.

In my Gemfile I've got:

gem 'mongoid' , git: 'https://github.com/mongoid/mongoid.git'

and in controllers I've:

params.require(:foo).permit! # allows everything, and bad security!!!

See this railscast: (http://railscasts.com/episodes/400-what-s-new-in-rails-4) or the code: (https://github.com/railscasts/400-what-s-new-in-rails-4)

review the controller code on the changes with strong_parameters, as I think this is what's getting you with the silent fails on updates :)

And on one of my models there are some pretty deep has_many :foo, and foo has_many :bar and bar has_many :baz of which I have accepts_nested_attributes_for on each.

So just saying you may want to try things out a little more or perhaps there was an update to underlinings on mongoid between when you tried and when I have been.

JoeManFoo
  • 161
  • 1
  • 6
  • Thanks for that. Strong parameters was the first thing I checked. I had included all the object parameters, and retried it with permit! as you suggested, but with no success. I ran bundle update to make sure I had the latest versions. It seems strange that CR+D work as expected but U still doesn't. I'll have to check all the details to make sure I haven't dome anything daft. Are you using Ruby v2? – user2241402 Apr 05 '13 at 18:29