inline_forms 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,23 +1,24 @@
1
1
  class InlineFormsController < ApplicationController
2
- unloadable # see http://dev.rubyonrails.org/ticket/6001
2
+ #unloadable # see http://dev.rubyonrails.org/ticket/6001
3
3
  # == Generic controller for the inline_forms plugin.
4
4
  # === Usage
5
- # If you have an Example class, then you can add a route like this:
6
- # <tt>map.resources :examples, :controller => :inline_forms</tt>
7
- # this will give you REST stuff without creating a sepearte examples_controller.rb
5
+ # If you have an Example class, make an ExampleController that is a subclass of InlineFormsController
6
+ # <tt>class ExampleController < InlineFormsController
7
+ # # add before filters if you want: before_filter :authenticate_user!, :only => :token
8
+ # # override methods or make your own, using @Klass instead of Example.
9
+ # # def index
10
+ # # @objects=@Klass.all
11
+ # # end
8
12
  # === How it works
9
- # The getKlass before_filter extracts the classname from the request. So, '/examples/1' and
10
- # '/examples?name=value' will result in @Klass being set to 'Example', which is the class.
13
+ # The getKlass before_filter extracts the class and puts it in @Klass
11
14
  # === Limited Access
12
15
  # the must_be_xhr_request before_filter is supposed to only perform the specific actions
13
- # if the request is an XhttpRequest. There is not much use perming the actions outside of
16
+ # if the request is an XhttpRequest. There is not much use permitting the actions outside of
14
17
  # the XhttpRequest context (except action => :index). Of course, this is not a security measure.
15
18
  before_filter :getKlass
16
19
  before_filter :must_be_xhr_request, :except => :index
17
- helper :inline_form
18
- include InlineFormHelper
20
+ include InlineFormsHelper # this might also be included in you application_controller with helper :all but it's not needed
19
21
  layout false
20
-
21
22
  # :index shows a list of all objects from class Klass, with all attribute values linked to the 'edit' action.
22
23
  # Each field (attribute) is edited seperately (so you don't edit an entire object!)
23
24
  # The link to 'new' allows you to create a new record.
@@ -26,7 +27,7 @@ class InlineFormsController < ApplicationController
26
27
  #
27
28
  def index
28
29
  nolayout = params[:layout] == 'false' || false
29
- @objects = @Klass.constantize.all
30
+ @objects = @Klass.all
30
31
  render( :layout => nolayout || 'inline_forms' )
31
32
  end
32
33
 
@@ -118,15 +119,13 @@ class InlineFormsController < ApplicationController
118
119
  redirect_to "/#{@Klass_pluralized}" if not request.xhr?
119
120
  end
120
121
 
121
- # Get the classname from the request uri.
122
- # /examples/1 => Example
123
- # /examples?field=name => Example
124
- #
122
+ # Get the class
125
123
  # Used in before_filter
126
124
  def getKlass #:doc:
127
- @Klass = request.request_uri.split(/[\/?]/)[1].classify
128
- @Klass_constantized = @Klass.constantize
129
- @Klass_underscored = @Klass.underscore
130
- @Klass_pluralized = @Klass_underscored.pluralize
125
+ @Klass = self.controller_name.classify.constantize
126
+ #request.request_uri.split(/[\/?]/)[1].classify
127
+ #@Klass_constantized = @Klass.constantize
128
+ #@Klass_underscored = @Klass.underscore
129
+ #@Klass_pluralized = @Klass_underscored.pluralize
131
130
  end
132
131
  end
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.2.0"
8
+ s.version = "0.2.1"
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares