inline_forms 0.2.0 → 0.2.1
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 +1 -1
- data/app/controllers/inline_forms_controller.rb +18 -19
- data/inline_forms.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
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,
|
6
|
-
# <tt>
|
7
|
-
#
|
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
|
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
|
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 :
|
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.
|
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
|
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 =
|
128
|
-
|
129
|
-
|
130
|
-
|
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
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|