Skip to content

Commit

Permalink
Fix relation generation for new record
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Jan 9, 2014
1 parent 3445b81 commit 547ae17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/friendly_id/scoped.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def scope_for_slug_generator
relation = relation.where(column => send(column))
end
if changed.include?(friendly_id_config.slug_column)
column = self.class.quoted_table_name + '.' + self.class.quoted_primary_key
relation = relation.where("#{column} <> ?", send(self.class.primary_key))
primary_key_name = self.class.primary_key
relation = relation.where.not(primary_key_name => send(primary_key_name))
end
relation
end
private :scope_for_slug_generator

def slug_generator
friendly_id_config.slug_generator_class.new(scope_for_slug_generator)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/friendly_id/slugged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def scope_for_slug_generator
scope = scope.friendly unless friendly_id_config.uses? :finders

if changed.include?(friendly_id_config.slug_column)
column = self.class.quoted_table_name + '.' + self.class.quoted_primary_key
scope = scope.where("#{column} <> ?", send(self.class.primary_key))
primary_key_name = self.class.primary_key
scope = scope.where.not(primary_key_name => send(primary_key_name))
end
scope
end
Expand Down

0 comments on commit 547ae17

Please # to comment.