inline_forms 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -54,19 +54,19 @@ class InlineFormsController < ApplicationController
|
|
54
54
|
# if the parent_class is not nill, we are in associated list and we don't search there.
|
55
55
|
# also, make sure the Model that you want to do a search on has a :name attribute. TODO
|
56
56
|
if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
|
57
|
-
conditions = [ @Klass.
|
57
|
+
conditions = [ @Klass.table_name + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
58
58
|
else
|
59
59
|
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
60
60
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
61
61
|
end
|
62
62
|
# if we are using cancan, then make sure to select only accessible records
|
63
63
|
if cancan_enabled?
|
64
|
-
@objects = @Klass.accessible_by(current_ability).order(@Klass.
|
64
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.table_name + "." + @Klass.order_by_clause).paginate(
|
65
65
|
:page => params[:page],
|
66
66
|
:per_page => @PER_PAGE || 12,
|
67
67
|
:conditions => conditions )
|
68
68
|
else
|
69
|
-
@objects = @Klass.order(@Klass.
|
69
|
+
@objects = @Klass.order(@Klass.table_name + "." + @Klass.order_by_clause).paginate(
|
70
70
|
:page => params[:page],
|
71
71
|
:per_page => @PER_PAGE || 12,
|
72
72
|
:conditions => conditions )
|
@@ -123,7 +123,7 @@ class InlineFormsController < ApplicationController
|
|
123
123
|
@PER_PAGE = 5 unless @parent_class.nil?
|
124
124
|
# for the logic behind the :conditions see the #index method.
|
125
125
|
if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
|
126
|
-
conditions = [ @Klass.
|
126
|
+
conditions = [ @Klass.table_name + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
127
127
|
else
|
128
128
|
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
129
129
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
@@ -132,9 +132,9 @@ class InlineFormsController < ApplicationController
|
|
132
132
|
if object.save
|
133
133
|
flash.now[:success] = t('success', :message => object.class.model_name.human)
|
134
134
|
if cancan_enabled?
|
135
|
-
@objects = @Klass.accessible_by(current_ability).order(@Klass.
|
135
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.table_name + "." + @Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
136
136
|
else
|
137
|
-
@objects = @Klass.order(@Klass.
|
137
|
+
@objects = @Klass.order(@Klass.table_name + "." + @Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
138
138
|
end
|
139
139
|
respond_to do |format|
|
140
140
|
format.js { render :list}
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|