Skip to content

Commit

Permalink
prevent rows being added to the user_plugins table if the user_id is …
Browse files Browse the repository at this point in the history
…null
  • Loading branch information
parndt committed Dec 6, 2009
1 parent 1f0a13a commit b5a9772
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vendor/plugins/authentication/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class User < ActiveRecord::Base
validates_uniqueness_of :login, :email, :case_sensitive => false
before_save :encrypt_password

serialize :plugins_column#, Array
serialize :plugins_column#, Array # this is seriously deprecated and will be removed later.

has_many :plugins, :class_name => "UserPlugin", :order => "position ASC"

Expand Down Expand Up @@ -78,11 +78,11 @@ def authenticated?(password)
end

def plugins=(plugin_titles)
self.plugins.delete_all
unless self.new_record? # don't add plugins when the user_id is NULL.
self.plugins.delete_all

plugin_titles.each do |plugin_title|
if plugin_title.is_a?(String)
self.plugins.find_or_create_by_title(plugin_title)
plugin_titles.each do |plugin_title|
self.plugins.find_or_create_by_title(plugin_title) if plugin_title.is_a?(String)
end
end
end
Expand Down

0 comments on commit b5a9772

Please sign in to comment.