chicks / sugarcrm

A ruby based REST Client for SugarCRM
MIT License
90 stars 64 forks source link

Rails23 backport #55

Closed jigfox closed 13 years ago

jigfox commented 13 years ago

This changes makes the sugarcrm gem usable with activesupport 2.3

this changes also makes the tests more independent from the specific SugarCRM-Server running on localhost with predefined admin-username

davidsulc commented 13 years ago

Wow, thanks for your work!

The gem currently relies quite a lot on class_attribute (e.g. in base.rb), which is provided by ActiveSupport >= 3.

What happens if you call SugarCRM::Account._module ? This isn't covered adequately in the test suite, as it is an issue that crops up primarily when dealing with customizations (e.g. custom module, relationships, etc.), as can be seen in (e.g.) in associations/association.rb.

Have you tried using the gem in with Active Support 2.3 along with a customized version of SugarCRM? (I can't test this at the moment.)

We'll also have to look into backporting some sort of rails generator...

jigfox commented 13 years ago

Hi,

actually the rails team backported the class_attribute feature to rails 2.3.9 so that is not a problem anymore, we (@xijo and me). I'm on holiday until monday. So I probably won't be able to do anything further, but if you have more questions, you can probably ask @xijo. Currently we are trying to make the connection lazy, so that your able to start the rails application even when the sugar server is down.

SugarCRM::Account._module works without errors

davidsulc commented 13 years ago

Ah, I was unaware of the class_attribute backport.

I see what you mean about the lazy connection not being fully implemented in Rails. You might want to look at self.const_missing in module_methods.rb, which implements lazy connection in the gem (when used standalone). Lazy connection in Rails should be easily implemented by adapting config_file_paths to include additional/different paths if the Rails constant is defined.

Let us know if you run into any problems, or need additional information.

chicks commented 13 years ago

Suh-weet!

chicks commented 13 years ago

BTW, I'll look into merging this tonight! If all the tests pass (including rails 2 and rails 3), then I'll cut a new gem.

davidsulc commented 13 years ago

Merged.

Tested against Rails 3 (Ruby 1.8.7 and 1.9.2) and Rails 2.3.9 (Ruby 1.8.7).

Question: should we look into implementing a generator for Rails 2?

chicks commented 13 years ago

Beautiful!

chicks commented 13 years ago

New gem is hot off the press.

David, I'll leave the "generator for Rails 2" question up to you. I'm open either way :)