Skip to content

Commit

Permalink
Simplify overidden exists?
Browse files Browse the repository at this point in the history
  • Loading branch information
norman committed Sep 3, 2011
1 parent fac576f commit 923a087
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/friendly_id/finder_methods.rb
Expand Up @@ -27,11 +27,7 @@ def find_one(id)
# @see FriendlyId::ObjectUtils
def exists?(id = nil)
return super if id.unfriendly_id?
join_dependency = construct_join_dependency_for_association_find
relation = construct_relation_for_association_find(join_dependency)
relation = relation.except(:select).select("1").limit(1)
relation = relation.where(@klass.friendly_id_config.query_field => id)
connection.select_value(relation.to_sql) ? true : false
super @klass.friendly_id_config.query_field => id
end
end
end

0 comments on commit 923a087

Please sign in to comment.