From 869f3b681566ffc2d77722b7e4831461a4e383d8 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Tue, 25 Jun 2013 18:36:42 +0800 Subject: [PATCH] fix object de-authorize failed. --- Gemfile | 2 +- app/models/prototype_auth.rb | 5 +++-- config/mongoid.yml | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 config/mongoid.yml diff --git a/Gemfile b/Gemfile index 6c63190a..0d435026 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ gem 'mongoid-encryptor', :require => 'mongoid/encryptor' gem 'rb-readline','~> 0.4.2' if RUBY_PLATFORM.downcase.include?("linux") -gem "impressionist", :git => 'git://github.com/charlotte-ruby/impressionist.git' +gem "impressionist",'1.2.0' #gem 'contacts' #gem 'event-calendar', :require => 'event_calendar'#, :git => 'git://github.com/elevation/event_calendar.git' diff --git a/app/models/prototype_auth.rb b/app/models/prototype_auth.rb index 666bc7a8..79cce96d 100644 --- a/app/models/prototype_auth.rb +++ b/app/models/prototype_auth.rb @@ -51,8 +51,9 @@ class PrototypeAuth end def remove_operation(item,obj) - if (self.send item).include? obj - (self.send item).delete obj + item = (item.to_s.singularize == item.to_s) ? "#{item.to_s}_id" : "#{item.to_s.singularize}_ids" + if (self.send item).include? obj.id + (self.send item).delete obj.id self.save! else false #should put error message for user not existed in list diff --git a/config/mongoid.yml b/config/mongoid.yml new file mode 100644 index 00000000..bc925ba3 --- /dev/null +++ b/config/mongoid.yml @@ -0,0 +1,24 @@ +defaults: &defaults + host: localhost + # slaves: + # - host: slave1.local + port: 27017 + # - host: slave2.local + # port: 27019 + +development: + <<: *defaults + database: demo_site_development +test: + <<: *defaults + database: test_site + +# set these environment variables on your prod server +production: + # host: <%= ENV['MONGOID_HOST'] %> + # port: <%= ENV['MONGOID_PORT'] %> + # username: <%= ENV['MONGOID_USERNAME'] %> + # password: <%= ENV['MONGOID_PASSWORD'] %> + # database: <%= ENV['MONGOID_DATABASE'] %> + <<: *defaults + database: demo_site_production