acts_as_multipart_form 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.rdoc +56 -1
- data/VERSION +1 -1
- data/acts_as_multipart_form.gemspec +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,61 @@
|
|
1
1
|
= acts_as_multipart_form
|
2
2
|
|
3
|
-
|
3
|
+
Create multipart forms in rails without using multiple routes. A controler mixin handles loading and saving data based on partials on a single route.
|
4
|
+
|
5
|
+
= How to use
|
6
|
+
|
7
|
+
== Install the gem with
|
8
|
+
|
9
|
+
gem install acts_as_multipart_form
|
10
|
+
|
11
|
+
== Install the migration and config with
|
12
|
+
|
13
|
+
rails generate acts_as_multipart_form:install
|
14
|
+
|
15
|
+
== Add the mixin to your controller
|
16
|
+
|
17
|
+
acts_as_multipart_form :name => :hire_form, :parts => [:person_info, :job_info], :model => "Person", :form_route => "person_hire_form"
|
18
|
+
|
19
|
+
The parts correspond to methods in the controller and partials in the controller's views folder. Additional methods called :person_info_update and :job_info_update are also necessary to handle saving the data.
|
20
|
+
|
21
|
+
Each form has a polymorphic relationship with a single record. This relationship is specified by the model key's value. This is how the form is loaded on the index page and the only association it has with the rest of the system.
|
22
|
+
|
23
|
+
Two routes can be specified for the form system. The form route corresponds to the route to the form itself. It's default value is model_name_form_name. In the example, the specified value would be the default value. The show route, specified with the tag :show_route is redirected to after the last part of the multipart form is submitted and passes validations. It defauls to model_name to correspond with the model's view page.
|
24
|
+
|
25
|
+
== Add the mixing to your model
|
26
|
+
|
27
|
+
multipart_formable :forms => [:hire_form]
|
28
|
+
|
29
|
+
This is currently only used for validations. If this is set, you can use a validation like this to only validate a field if the save is coming from a specific multipart form part.
|
30
|
+
|
31
|
+
validates_presence_of :name, :if => :hire_form_personal_info?
|
32
|
+
|
33
|
+
== Adding a breadcrumb to the form page
|
34
|
+
|
35
|
+
<%= render "multipart_form/breadcrumb" %>
|
36
|
+
|
37
|
+
This adds links to each form page and next/previous links to the page. It must be on a multipart form view to work. The configuration options in the initializer can be used to change the output of the partial.
|
38
|
+
|
39
|
+
== Adding form part links to the index page
|
40
|
+
|
41
|
+
=== On the controller
|
42
|
+
|
43
|
+
@people = Person.all
|
44
|
+
load_multipart_form_index_links(:hire_form, @people)
|
45
|
+
|
46
|
+
=== On the view
|
47
|
+
|
48
|
+
<%= render "multipart_form/index_links", :locals => {:form_subject => person } %>
|
49
|
+
|
50
|
+
Creates links to each form part for the given form subject. The load_multipart_form_index_links must be called to load the data for the links. The configuration options in the initializer can be used to change the output of the partial.
|
51
|
+
|
52
|
+
|
53
|
+
== Future work
|
54
|
+
|
55
|
+
* Fix the index links loading so that the user does not have to explicitly call a method when they are needed
|
56
|
+
* Improve the behavior of the previous and next links in the breadcrumb
|
57
|
+
* Add A controller and views generator to generate the files in the rails project so they can be edited for project specific needs
|
58
|
+
* Improve code quality of the mixin where it makes variables available to views
|
4
59
|
|
5
60
|
== Contributing to acts_as_multipart_form
|
6
61
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_multipart_form}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Jeremiah Hemphill}, %q{Ethan Pemble}]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: acts_as_multipart_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jeremiah Hemphill
|
@@ -275,7 +275,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
275
275
|
requirements:
|
276
276
|
- - ">="
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
hash:
|
278
|
+
hash: -4212957645854622535
|
279
279
|
segments:
|
280
280
|
- 0
|
281
281
|
version: "0"
|