Skip to content

Commit

Permalink
postgreSQL is picky about doing a LIKE query
Browse files Browse the repository at this point in the history
  • Loading branch information
joemsak committed Jun 22, 2011
1 parent bce2877 commit 3b975e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions app/controllers/admin/blog/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ def uncategorized
end

def tags
op = case ActiveRecord::Base.connection.adapter_name.downcase
when 'postgresql'
'SIMILAR TO'
else
'LIKE'
end
wildcard = case ActiveRecord::Base.connection.adapter_name.downcase
when 'postgresql'
'.*'
else
'%'
end
@tags = BlogPost.tag_counts_on(:tags).where(
["tags.name LIKE ?", "%#{params[:term].to_s.downcase}%"]
).map { |tag| {:id => tag.id, :value => tag.name}}
["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"]
).map { |tag| {:id => tag.id, :value => tag.name}}
render :json => @tags.flatten
end

Expand Down
2 changes: 1 addition & 1 deletion lib/refinery/blog/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Blog
class Version
@major = 1
@minor = 6
@tiny = 0
@tiny = 1

class << self
attr_reader :major, :minor, :tiny
Expand Down
2 changes: 1 addition & 1 deletion refinerycms-blog.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{refinerycms-blog}
s.version = %q{1.6.0}
s.version = %q{1.6.1}
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
s.date = %q{2011-06-21}
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
Expand Down

0 comments on commit 3b975e0

Please sign in to comment.