inline_forms 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.16
1
+ 0.9.17
@@ -54,11 +54,9 @@ class InlineFormsController < ApplicationController
54
54
  @parent_class = params[:parent_class]
55
55
  @parent_id = params[:parent_id]
56
56
  @ul_needed = params[:ul_needed]
57
- if @Klass.new.respond_to? :name
58
- @parent_class.nil? ? conditions = ["name like ?", "%#{params[:search]}%" ] : conditions = [ "name like ? AND #{@parent_class.foreign_key} = ?", "%#{params[:search]}%" , @parent_id ]
59
- else
60
- @parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
61
- end
57
+ # if the parent_class is not nill, we are in associated list and we don't search there.
58
+ # also, make sure the Model that you want to do a search on has a :name attribute. TODO
59
+ @parent_class.nil? ? conditions = ["name like ?", "%#{params[:search]}%" ] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
62
60
  if cancan_enabled?
63
61
  @objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
64
62
  else
@@ -120,11 +118,8 @@ class InlineFormsController < ApplicationController
120
118
  end
121
119
  @parent_class = params[:parent_class]
122
120
  @parent_id = params[:parent_id]
123
- if object.respond_to? :name
124
- @parent_class.nil? ? conditions = ["name like ?", "%#{params[:search]}%" ] : conditions = [ "name like ? AND #{@parent_class.foreign_key} = ?", "%#{params[:search]}%" , @parent_id ]
125
- else
126
- @parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
127
- end
121
+ # for the logic behind the :conditions see the #index method.
122
+ @parent_class.nil? ? conditions = ["name like ?", "%#{params[:search]}%" ] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
128
123
  object[@parent_class.foreign_key] = @parent_id unless @parent_class.nil?
129
124
  if object.save
130
125
  flash.now[:success] = "Successfully created #{object.class.to_s.underscore}."
data/inline_forms.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{inline_forms}
8
- s.version = "0.9.16"
8
+ s.version = "0.9.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ace Suares"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 16
10
- version: 0.9.16
9
+ - 17
10
+ version: 0.9.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares