Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ThinkingSphinx conflicts with ransack in admin controllers #1532

Closed
wants to merge 1 commit into from

4 participants

@ademidov

I use ThinkingSphinx in my project and after the upgrade to 1.1 the problem occurred - Admin::ProductsController stopped working due to the use of the method .search already defined by TS (ransack does not define its own method .search in conflict situations).

As .search is just an alias for .ransack, I replaced it at all controllers for consistency.

@BDQ
Owner

I'm luke warm on this commit to be honest, the .ransack method doesn't really explain what the method does for our users ( .search is a lot cleaner).

Does ThinkingSphinx provide alternative to .search that you can use?

@schof - any opinion on this?

@ademidov

No, TS has only .search method.

And another problem is a code from ransack:

alias :search :ransack unless base.method_defined? :search

So.. it does not define a .search method in model when it already exists

@BDQ
Owner

I can see how that's a pain, I'm just reluctant to accept this change with only one user requesting it.

Anyone else care to comment?

@schof
Owner

There's probably more than one user running TS and Spree out there. I do agree with @BDQ that ransack is not a very descriptive method name. What about defining another alias (ransack_search) or something like this instead?

@BDQ
Owner

ransack_search is a good idea.

@radar
Collaborator

Do we want extra code in the Spree project that defines this new ransack_search method, or do we just educate people that the ransack method comes from within the ransack gem?

@radar radar closed this pull request from a commit
@ademidov ademidov .search methods changed to .ransack
Closes #1532
708fbb9
@radar radar closed this in 708fbb9
@radar
Collaborator

Merged into 1-1-stable and master. Thanks @alekseydem!

@joahking joahking referenced this pull request from a commit in joahking/spree
@ademidov ademidov .search methods changed to .ransack
Closes #1532
4fabc52
@tvdeyen tvdeyen referenced this pull request from a commit in magiclabs/spree
@ademidov ademidov .search methods changed to .ransack
Closes #1532
7723b14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 13, 2012
  1. @ademidov
This page is out of date. Refresh to see the latest.
View
2  api/app/controllers/spree/api/v1/orders_controller.rb
@@ -15,7 +15,7 @@ def show
end
def search
- @orders = Order.search(params[:q]).result.page(params[:page])
+ @orders = Order.ransack(params[:q]).result.page(params[:page])
render :index
end
View
2  api/app/controllers/spree/api/v1/products_controller.rb
@@ -7,7 +7,7 @@ def index
end
def search
- @products = product_scope.search(params[:q]).result.page(params[:page])
+ @products = product_scope.ransack(params[:q]).result.page(params[:page])
render :index
end
View
2  core/app/controllers/spree/admin/orders_controller.rb
@@ -27,7 +27,7 @@ def index
params[:q][:completed_at_lt] = params[:q].delete(:created_at_lt)
end
- @search = Order.search(params[:q])
+ @search = Order.ransack(params[:q])
@orders = @search.result.includes([:user, :shipments, :payments]).page(params[:page]).per(Spree::Config[:orders_per_page])
respond_with(@orders)
end
View
6 core/app/controllers/spree/admin/products_controller.rb
@@ -64,8 +64,8 @@ def json_data
when 'basic'
collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json
else
- collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},
- :images => {:only => [:id], :methods => :mini_url}}},
+ collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},
+ :images => {:only => [:id], :methods => :mini_url}}},
:images => {:only => [:id], :methods => :mini_url}, :master => {}})
end
end
@@ -84,7 +84,7 @@ def collection
params[:q][:s] ||= "name asc"
- @search = super.search(params[:q])
+ @search = super.ransack(params[:q])
@collection = @search.result.
group_by_products_id.
includes([:master, {:variants => [:images, :option_values]}]).
View
2  core/app/controllers/spree/admin/reports_controller.rb
@@ -34,7 +34,7 @@ def sales_total
params[:q][:meta_sort] ||= "created_at.desc"
- @search = Order.complete.search(params[:q])
+ @search = Order.complete.ransack(params[:q])
@orders = @search.result
@item_total = @orders.sum(:item_total)
@adjustment_total = @orders.sum(:adjustment_total)
View
2  core/app/controllers/spree/admin/users_controller.rb
@@ -24,7 +24,7 @@ def dismiss_banner
def collection
return @collection if @collection.present?
unless request.xhr?
- @search = Spree::User.registered.search(params[:q])
+ @search = Spree::User.registered.ransack(params[:q])
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
else
#disabling proper nested include here due to rails 3.1 bug
View
2  core/app/controllers/spree/admin/zones_controller.rb
@@ -13,7 +13,7 @@ def new
def collection
params[:q] ||= {}
params[:q][:meta_sort] ||= "ascend_by_name"
- @search = super.search(params[:q])
+ @search = super.ransack(params[:q])
@zones = @search.result.page(params[:page]).per(Spree::Config[:orders_per_page])
end
Something went wrong with that request. Please try again.