Closed alexdesi closed 13 years ago
Sure - you are hitting a validation error. The gem enforces "module required fields" when you try and save a record (required fields can be changed in SugarCRM Studio). You'll need to set Team Name and Team Count before your save will work. You can view the required fields on an object with:
SugarCRM::Contact.new.required_fields
=> [:last_name]
I'm not sure what team_count is used for, but you can try setting it to 0.
BTW, teams are in Pro and Enterprise versions only (which we don't test against) which is why the example doesn't exactly line up with what you are trying to do.
To expand on chicks' answer, the gem will check for required fields and expose the results much like rails would:
c = SugarCRM::Contact.new
c.valid? # => false
c.errors # => {"last_name" => ["cannot be blank"]}
The error you're seeing is from the fact that the record isn't valid before save!
is called on it. You can either specify a team name and count (possibly automatically by extending the gem, as detailed at http://davidsulc.com/blog/2011/04/05/ruby-gem-for-sugarcrm-advanced-use/), or try to remove the requirements in the SugarCRM Studio interface.
Yes, it is on Pro version, thank you for your suggestions ! now it works :) Alessandro
When I try to Add a Contact to an Account, exactly as in https://github.com/chicks/sugarcrm#readme, I get the message "Team name cannot be blank":
irb-shell > a.contacts << c SugarCRM::InvalidRecord: Team name cannot be blank, Team count cannot be blank from /home/banjo/.rvm/gems/ruby-1.8.7-p334/gems/sugarcrm-0.9.14/lib/sugarcrm/attributes/attribute_methods.rb:158:in save_modified_attributes!' from /home/banjo/.rvm/gems/ruby-1.8.7-p334/gems/sugarcrm-0.9.14/lib/sugarcrm/base.rb:169:in
save!' from /home/banjo/.rvm/gems/ruby-1.8.7-p334/gems/sugarcrm-0.9.14/lib/sugarcrm/associations/association_collection.rb:68:in
<<' from (irb):135Any idea about that ?
Thanks, Alessandro