sinatra-formhelpers-ng 1.6.2 → 1.7.0
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/lib/sinatra/form_helpers.rb +6 -8
- data/spec/form_helpers_spec.rb +4 -4
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/lib/sinatra/form_helpers.rb
CHANGED
@@ -13,14 +13,12 @@ module Sinatra
|
|
13
13
|
# etc.
|
14
14
|
def form(action, method=:get, options={}, &block)
|
15
15
|
method_input = ''
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
method = :post
|
23
|
-
end
|
16
|
+
# the docs suggest using ':create', ':update', or ':delete'
|
17
|
+
# but you can use any symbol for the method value
|
18
|
+
# allows for more than 3 forms on a single page
|
19
|
+
if method.is_a? Symbol
|
20
|
+
method_input = %Q(<input type="hidden" name="_method" value="#{method}" />)
|
21
|
+
method = :post
|
24
22
|
end
|
25
23
|
action = "/#{action}" if action.is_a? Symbol
|
26
24
|
|
data/spec/form_helpers_spec.rb
CHANGED
@@ -20,7 +20,7 @@ require File.expand_path 'spec_helper', File.dirname(__FILE__)
|
|
20
20
|
|
21
21
|
describe "Sinatra::FormHelpers methods" do
|
22
22
|
it "renders an anchor tag" do
|
23
|
-
fh.form(:person, :create).should == '<form action="/person" method="POST"
|
23
|
+
fh.form(:person, :create).should == '<form action="/person" method="POST"><input type="hidden" name="_method" value="create" />'
|
24
24
|
end
|
25
25
|
it 'renders a form tag' do
|
26
26
|
fh.form(:person, :update, :action => "/people/14").should ==
|
@@ -32,13 +32,13 @@ describe "Sinatra::FormHelpers methods" do
|
|
32
32
|
end
|
33
33
|
it 'renders a form tag (3)' do
|
34
34
|
fh.form("/people", :create).should ==
|
35
|
-
'<form action="/people" method="POST"
|
35
|
+
'<form action="/people" method="POST"><input type="hidden" name="_method" value="create" />'
|
36
36
|
end
|
37
37
|
it 'renders a nested form tag' do
|
38
38
|
fh.form(:person, :create) do |f|
|
39
39
|
# f.input(:first_name)
|
40
40
|
f.input(:last_name)
|
41
|
-
end.should == '<form action="/person" method="POST"><fieldset>' +
|
41
|
+
end.should == '<form action="/person" method="POST"><input type="hidden" name="_method" value="create" /><fieldset>' +
|
42
42
|
# '<input id="person_first_name" name="person[first_name]" type="text" />' +
|
43
43
|
'<input id="person_last_name" name="person[last_name]" type="text" />' +
|
44
44
|
'</fieldset></form>'
|
@@ -299,7 +299,7 @@ describe "Sinatra::FormHelpers in app" do
|
|
299
299
|
end
|
300
300
|
|
301
301
|
get '/form'
|
302
|
-
last_response.body.should == %q(<form action="/person" method="POST"
|
302
|
+
last_response.body.should == %q(<form action="/person" method="POST"><input type="hidden" name="_method" value="create" />)
|
303
303
|
end
|
304
304
|
|
305
305
|
# it 'renders a form_for style tag' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-formhelpers-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bacon
|
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: 1409853244715081074
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|