Permalink
Browse files

Small code improvement

  • Loading branch information...
1 parent bac5b53 commit 1284cadb92bd8da7f008e5656d42212960bfa8ce @johnnyshields johnnyshields committed Jan 12, 2014
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/by_star/orm/active_record/by_star.rb
View
8 lib/by_star/orm/active_record/by_star.rb
@@ -39,14 +39,14 @@ def after_query(time, options={})
def previous(options={})
field = self.class.by_star_start_field
- field = field.split(".").last
- self.class.where("#{field} < ?", self.send(field)).reorder("#{field} DESC").first
+ value = self.send(field.split(".").last)
+ self.class.where("#{field} < ?", value).reorder("#{field} DESC").first
end
def next(options={})
field = self.class.by_star_start_field
- field = field.split(".").last
- self.class.where("#{field} > ?", self.send(field)).reorder("#{field} ASC").first
+ value = self.send(field.split(".").last)
+ self.class.where("#{field} > ?", value).reorder("#{field} ASC").first
end
end
end

0 comments on commit 1284cad

Please sign in to comment.