Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

use non-breaking space to join ordering indicator to sort_link #63

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ source :rubygems

# Don't do a "gemspec" here. Seriously. It jacks up Jeweler.

gem "activerecord", "~> 3.1"
gem "activesupport", "~> 3.1"
gem "polyamorous", "~> 0.5.0"
gem "actionpack", "~> 3.1"
gem "activerecord", "4.0.0.beta1"
gem "activesupport", "4.0.0.beta1"
gem "polyamorous", :git => "https://github.com/ernie/polyamorous.git"
gem "actionpack", "4.0.0.beta1"

group :development do
gem "shoulda", "~> 2.11"
Expand Down
8 changes: 4 additions & 4 deletions lib/meta_search/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Builder
# for how it will expose this model and its associations to your controllers/views.
def initialize(base_or_relation, opts = {})
opts = opts.dup
@relation = base_or_relation.scoped
@relation = base_or_relation.all
@base = @relation.klass
@search_key = (opts.delete(:search_key) || 'search').to_s
@options = opts # Let's just hang on to other options for use in authorization blocks
Expand All @@ -51,13 +51,13 @@ def get_association(assoc, base = @base)

def get_attribute(name, parent = @join_dependency.join_base)
attribute = nil
if get_column(name, parent.active_record)
if get_column(name, parent.base_klass)
attribute = parent.table[name]
elsif (segments = name.to_s.split(/_/)).size > 1
remainder = []
found_assoc = nil
while remainder.unshift(segments.pop) && segments.size > 0 && !found_assoc do
if found_assoc = get_association(segments.join('_'), parent.active_record)
if found_assoc = get_association(segments.join('_'), parent.base_klass)
if found_assoc.options[:polymorphic]
unless delimiter = remainder.index('type')
raise PolymorphicAssociationMissingTypeError, "Polymorphic association specified without a type"
Expand All @@ -82,7 +82,7 @@ def get_attribute(name, parent = @join_dependency.join_base)
# MetaSearch::Where
def build(option_hash)
opts = option_hash.dup || {}
@relation = @base.scoped
@relation = @base.all
opts.stringify_keys!
opts = collapse_multiparameter_options(opts)
assign_attributes(opts)
Expand Down
12 changes: 6 additions & 6 deletions lib/meta_search/helpers/form_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module MetaSearch
module Helpers
module FormHelper
def apply_form_for_options!(object_or_array, options)
if object_or_array.is_a?(MetaSearch::Builder)
builder = object_or_array
options[:url] ||= polymorphic_path(object_or_array.base)
elsif object_or_array.is_a?(Array) && (builder = object_or_array.detect {|o| o.is_a?(MetaSearch::Builder)})
options[:url] ||= polymorphic_path(object_or_array.map {|o| o.is_a?(MetaSearch::Builder) ? o.base : o})
def apply_form_for_options!(record,object,options)
if object.is_a?(MetaSearch::Builder)
builder = object
options[:url] ||= polymorphic_path(object.base)
elsif object.is_a?(Array) && (builder = object.detect {|o| o.is_a?(MetaSearch::Builder)})
options[:url] ||= polymorphic_path(object.map {|o| o.is_a?(MetaSearch::Builder) ? o.base : o})
else
super
return
Expand Down
2 changes: 1 addition & 1 deletion lib/meta_search/helpers/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def sort_link(builder, attribute, *args)
'meta_sort' => [attr_name, new_order].join('.')
)
)
link_to [ERB::Util.h(name), order_indicator_for(current_order)].compact.join(' ').html_safe,
link_to [ERB::Util.h(name), order_indicator_for(current_order)].compact.join('&nbsp').html_safe,
url_for(options),
html_options
end
Expand Down
28 changes: 5 additions & 23 deletions meta_search.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,10 @@ Gem::Specification.new do |s|
s.rubygems_version = "1.8.15"
s.summary = "Object-based searching (and more) for simply creating search forms."

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<activerecord>, ["~> 3.1"])
s.add_runtime_dependency(%q<activesupport>, ["~> 3.1"])
s.add_runtime_dependency(%q<polyamorous>, ["~> 0.5.0"])
s.add_runtime_dependency(%q<actionpack>, ["~> 3.1"])
s.add_development_dependency(%q<shoulda>, ["~> 2.11"])
else
s.add_dependency(%q<activerecord>, ["~> 3.1"])
s.add_dependency(%q<activesupport>, ["~> 3.1"])
s.add_dependency(%q<polyamorous>, ["~> 0.5.0"])
s.add_dependency(%q<actionpack>, ["~> 3.1"])
s.add_dependency(%q<shoulda>, ["~> 2.11"])
end
else
s.add_dependency(%q<activerecord>, ["~> 3.1"])
s.add_dependency(%q<activesupport>, ["~> 3.1"])
s.add_dependency(%q<polyamorous>, ["~> 0.5.0"])
s.add_dependency(%q<actionpack>, ["~> 3.1"])
s.add_dependency(%q<shoulda>, ["~> 2.11"])
end
s.add_dependency(%q<activerecord>, [">= 3.1"])
s.add_dependency(%q<activesupport>, [">= 3.1"])
s.add_dependency(%q<polyamorous>, [">= 0.5.0"])
s.add_dependency(%q<actionpack>, [">= 3.1"])
# s.add_dependency(%q<shoulda>, ["~> 2.11"])
end