inline_forms 0.9.9 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.9
1
+ 0.9.10
@@ -111,19 +111,19 @@ class InlineFormsController < ApplicationController
111
111
  def create
112
112
  object = @Klass.new
113
113
  @update_span = params[:update]
114
- # update each field of the record
115
114
  attributes = object.inline_forms_attribute_list
116
115
  attributes.each do | attribute, name, form_element |
117
116
  send("#{form_element.to_s}_update", object, attribute) unless form_element == :associated
118
117
  end
118
+ @parent_class = params[:parent_class]
119
+ @parent_id = params[:parent_id]
120
+ @parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
121
+ object[@parent_class.foreign_key] = @parent_id unless @parent_class.nil?
119
122
  if object.save
120
123
  flash.now[:success] = "Successfully created #{object.class.to_s.underscore}."
121
124
  else
122
125
  flash.now[:error] = "Failed to create #{object.class.to_s.underscore}."
123
126
  end
124
- @parent_class = params[:parent_class]
125
- @parent_id = params[:parent_id]
126
- @parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
127
127
  if cancan_enabled?
128
128
  @objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
129
129
  else
@@ -16,9 +16,9 @@ end
16
16
  def check_list_edit(object, attribute)
17
17
  object.send(attribute).build if object.send(attribute).empty?
18
18
  if cancan_enabled?
19
- values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability).order(@Klass.order_by_clause)
19
+ values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
20
20
  else
21
- values = object.send(attribute).first.class.name.constantize.order(@Klass.order_by_clause)
21
+ values = object.send(attribute).first.class.name.constantize.order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
22
22
  end
23
23
  out = '<div class="edit_form_checklist">'
24
24
  out << '<ul>'
@@ -9,9 +9,9 @@ end
9
9
  def dropdown_edit(object, attribute)
10
10
  object.send('build_' + attribute.to_s) unless object.send(attribute)
11
11
  if cancan_enabled?
12
- values = object.send(attribute).class.name.constantize.accessible_by(current_ability).order(@Klass.order_by_clause)
12
+ values = object.send(attribute).class.name.constantize.accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
13
13
  else
14
- values = object.send(attribute).class.name.constantize.order(@Klass.order_by_clause)
14
+ values = object.send(attribute).class.name.constantize.order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
15
15
  end
16
16
  # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
17
17
  collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_presentation', :selected => object.send(attribute).id)
@@ -39,9 +39,9 @@ they are @object. We need this magic here to rewrite all the @variables to varia
39
39
  <% conditions = [ "#{parent_class.name.foreign_key} = ?", parent_id ] %>
40
40
 
41
41
  <% if cancan_enabled? %>
42
- <% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
42
+ <% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
43
43
  <% else %>
44
- <% objects = parent_class.find(parent_id).send(attribute).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
44
+ <% objects = parent_class.find(parent_id).send(attribute).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
45
45
  <% end %>
46
46
 
47
47
  <% end %>
data/inline_forms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{inline_forms}
8
- s.version = "0.9.9"
8
+ s.version = "0.9.10"
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"]
12
- s.date = %q{2011-05-30}
12
+ s.date = %q{2011-06-02}
13
13
  s.description = %q{Inline Forms aims to ease the setup of forms that provide inline editing. The field list can be specified in the model.}
14
14
  s.email = %q{ace@suares.an}
15
15
  s.extra_rdoc_files = [
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: 41
4
+ hash: 47
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 9
10
- version: 0.9.9
9
+ - 10
10
+ version: 0.9.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-30 00:00:00 -04:00
18
+ date: 2011-06-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency