apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Rails 3.2: can't write unknown attribute `gmaps' when using attr_accessor #144

Closed niuage closed 12 years ago

niuage commented 12 years ago

I might be mistaken, but I don't think the following will work in rails 3.2.0 when using an attr_accessor for :checker. (attr_accessor :gmaps for instance):

if Gmaps4rails.condition_eval(self, gmaps4rails_options[:check_process])
    self[gmaps4rails_options[:checker]] = true
end

https://github.com/rails/rails/issues/4583

apneadiving commented 12 years ago

I see but didn't test myself, do you have some suggestion to fix this?

niuage commented 12 years ago

Maybe:

self.send("#{gmaps4rails_options[:checker]}=", true)

It's not exactly the same thing but it should work. Maybe I'll try it, but for now, I left my rails 3.2 branch and went back to 3.1. It will be something to think about when you upgrade to rails 3.2.

ryanb commented 12 years ago

I'm not using attr_accessor but I'm seeing a similar exception in Rails 3.2.1:

NoMethodError (undefined method `gmaps' for #<User:0x007fd06c47c8b0>)
activemodel (3.2.1) lib/active_model/attribute_methods.rb:407:in `method_missing'
activerecord (3.2.1) lib/active_record/attribute_methods.rb:126:in `method_missing'
gmaps4rails (1.4.3) lib/gmaps4rails/acts_as_gmappable.rb:15:in `process_geocoding'
...
niuage commented 12 years ago

I guess that in your case, the part failing is:

self.send(gmaps4rails_options[:checker]) == true

But honestly, I can't see why if you have a gmaps column in your User model...

apneadiving commented 12 years ago

I'll install Rails 3.2 to have a look.

apneadiving commented 12 years ago

@niuage : thanks for report, bug fixed and 1.4.4 released. @ryanb : sorry, I don't know how to reproduce the bug, could you please tell me a bit more?

niuage commented 12 years ago

Cool, thanks!

ryanb commented 12 years ago

It may have been related to the same problem, I'll give it a try and see if it's fixed now.