magic_form 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -24,9 +24,12 @@ Also, you can define your own attribute layer message. Example:
24
24
 
25
25
  = raw magic_form(@user, :name => "User name: ", :submit => "Save")
26
26
 
27
+ You can add a nested resource, like a *user* that is an *admin*. Example:
28
+
29
+ = raw magic_form(:admin, @user)
30
+
27
31
  ## To Do
28
32
 
29
- * Implement nested resources compatibility.
30
33
  * Implement a *do* cycle.
31
34
 
32
35
  ## Contributing to magic_form
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/magic_form.rb CHANGED
@@ -21,7 +21,7 @@ module ActionView
21
21
  end
22
22
 
23
23
  form_eval << "f.submit '#{options[:submit] || 'submit' }'"
24
- out = form_for resource do |f|
24
+ out = form_for resources do |f|
25
25
  form_eval.each do |c|
26
26
  form_content << "#{eval(c)}"
27
27
  end
@@ -0,0 +1,73 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{magic_form}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Luis Galaviz"]
12
+ s.date = %q{2010-12-01}
13
+ s.description = %q{Generate a form using a specific resource}
14
+ s.email = %q{luis.galaviz@crowdint.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/magic_form.rb",
28
+ "magic_form.gemspec",
29
+ "test/helper.rb",
30
+ "test/test_magic_form.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/MGalv/magic_form}
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{Generate a form using a specific resource}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/test_magic_form.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<ruby-debug19>, [">= 0"])
48
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
49
+ s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
50
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
53
+ s.add_development_dependency(%q<rcov>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
56
+ s.add_dependency(%q<rails>, [">= 0"])
57
+ s.add_dependency(%q<sqlite3>, [">= 0"])
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
65
+ s.add_dependency(%q<rails>, [">= 0"])
66
+ s.add_dependency(%q<sqlite3>, [">= 0"])
67
+ s.add_dependency(%q<shoulda>, [">= 0"])
68
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
69
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
70
+ s.add_dependency(%q<rcov>, [">= 0"])
71
+ end
72
+ end
73
+
data/test/helper.rb CHANGED
@@ -28,6 +28,9 @@ end
28
28
  MagicForm::Application.routes.draw do
29
29
  match '/:controller(/:action(/:id))'
30
30
  resource :products
31
+ resource :admin do
32
+ resource :products
33
+ end
31
34
  end
32
35
 
33
36
  ActionController::Base.send :include, MagicForm::Application.routes.url_helpers
@@ -16,7 +16,7 @@ class MagicFormTest < ActionView::TestCase
16
16
 
17
17
  context "having a product create a form with the Product attributes" do
18
18
 
19
- should "with no options" do
19
+ should "work with no options" do
20
20
  assert_equal magic_form(@product),
21
21
  (form_for @product do |f|
22
22
  form_content = ""
@@ -27,7 +27,7 @@ class MagicFormTest < ActionView::TestCase
27
27
  end)
28
28
  end
29
29
 
30
- should "with options" do
30
+ should "work with options" do
31
31
  assert_equal magic_form(@product, :name => "Product name: "),
32
32
  (form_for @product do |f|
33
33
  form_content = ""
@@ -37,5 +37,16 @@ class MagicFormTest < ActionView::TestCase
37
37
  form_content
38
38
  end)
39
39
  end
40
+
41
+ should "play nice with nested resources" do
42
+ assert_equal magic_form(:admin, @product),
43
+ (form_for [:admin, @product] do |f|
44
+ form_content = ""
45
+ form_content << (f.label :name)
46
+ form_content << (f.text_field :name)
47
+ form_content << (f.submit 'submit')
48
+ form_content
49
+ end)
50
+ end
40
51
  end
41
52
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luis Galaviz
@@ -130,6 +130,7 @@ files:
130
130
  - Rakefile
131
131
  - VERSION
132
132
  - lib/magic_form.rb
133
+ - magic_form.gemspec
133
134
  - test/helper.rb
134
135
  - test/test_magic_form.rb
135
136
  has_rdoc: true
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
147
  requirements:
147
148
  - - ">="
148
149
  - !ruby/object:Gem::Version
149
- hash: -1016163088646830549
150
+ hash: 1201021153162256010
150
151
  segments:
151
152
  - 0
152
153
  version: "0"