问题描述:

I'm having problems doing some simple stuff, I'm not sure if I'm doing something wrong. I'm using the most recent versions of Ruby and Sinatra (1.9.3 and 1.3.3) under Windows

My main code is:

require 'sinatra'

get '/form' do

erb :form

end

post '/form' do

"Value: '#{params[:somevalue]}'"

end

My ERB:

<form action="/form" method="post">

<input type="text" name"somevalue">

<input type="submit">

</form>

When I press submit, it won't show the values. It'll just show: Value: ''

I even tried with a plain HTML (with the same result).

These are my request headers:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3

Accept-Encoding:gzip,deflate,sdch

Accept-Language:es,en-US;q=0.8,en;q=0.6

Cache-Control:max-age=0

Connection:keep-alive

Content-Length:0

Content-Type:application/x-www-form-urlencoded

Host:localhost:4567

Origin:http://localhost:4567

Referer:http://localhost:4567/form

User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.91 Safari/537.11

Do I need to configure something?

网友答案:

You're missing a = after name in your .erb

Works for me after I added this.

网友答案:
<form action="/form" method="post">
    <input type="text" name="somevalue">
    <input type="submit">
</form>

you have missed equal sign

相关阅读:
Top