Ruby & Forms

Hi folks.

I’m trying to get my head around the implementation of Ruby forms. This is not Rails. I’m messing around in Sinatra and wanted to know how to receive submitted forms. I’ve looked at CGI and the params tag, but I’m unclear as to which one should be used.

Any urls and insight appreciated as I can’t find much out there. I’m confused between the two applications and I can’t seem to get params to work properly.

Cheers

I do not understanding so much your question (my english is not good)
but, here I come:

For write form, I suggest you to use a template engine

slim is a good one :wink:

for get forms values in sinatra, do a post methods and use the params
hash

post '/' do

  puts params['fieldname']

end

The params hash value always contain the request info...

For work with sinatra, ALL you need is in the README

http://www.sinatrarb.com/intro.html

Thread name: "Ruby & Forms"
Mail number: 1
In reply to: Bee.Lists

···

Date: Sat, Dec 13, 2014

Hi folks.

I’m trying to get my head around the implementation of Ruby forms. This is not Rails. I’m messing around in Sinatra and wanted to know how to receive submitted forms. I’ve looked at CGI and the params tag, but I’m unclear as to which one should be used.

Any urls and insight appreciated as I can’t find much out there. I’m confused between the two applications and I can’t seem to get params to work properly.

Cheers

Hello,

Hi folks.

I’m trying to get my head around the implementation of Ruby forms. This is not Rails. I’m messing around in Sinatra and wanted to know how to receive submitted forms. I’ve looked at CGI and the params tag, but I’m unclear as to which one should be used.

Any urls and insight appreciated as I can’t find much out there. I’m confused between the two applications and I can’t seem to get params to work properly.

I’m building a small app using Sinatra. Here you can see the routes[1] and the views[2].

The “routes" are composed of two ‘paths’ the ‘get’ and the ‘post’ which ‘redirects’ depending on the situation.

The “views” are made using HAML which is a syntax-sugar for HTML like ERB, LESS, etc. I’m using CSS but you could use SASS instead if you like it...

NOTE: I’m using an MVC architecture (also called modular) Sinatra which you can see here: GitHub - atmosx/pritory: Price tracking application for small businesses. based on riblits[3] skeleton.

If you need more details feel free to ask.

Cheers

[1] pritory/routes/add_product.rb at master · atmosx/pritory · GitHub
[2] pritory/views/add_product.haml at master · atmosx/pritory · GitHub
[3] GitHub - Phrogz/riblits: Shell for new Sinatra Applications

Panagiotis (atmosx) Atmatzidis

email: atma@convalesco.org
URL: http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

"As you set out for Ithaca, hope the voyage is a long one, full of adventure, full of discovery [...]" - C. P. Cavafy

···

On 13 Dec 2014, at 18:31, Bee.Lists <bee.lists@gmail.com> wrote:

Does Ruby qua Ruby even have a concept of HTML forms? It seems like
that'd be something that would exist only in the context of
Ruby+RailsOrSinatra. I think that for someone to answer your question,
they'd have to understand Sinatra's form handling, rather than Ruby's.

···

On Sat, Dec 13, 2014 at 10:42 AM, Panagiotis Atmatzidis <atma@convalesco.org> wrote:

Hello,

On 13 Dec 2014, at 18:31, Bee.Lists <bee.lists@gmail.com> wrote:

Hi folks.

I’m trying to get my head around the implementation of Ruby forms. This is
not Rails. I’m messing around in Sinatra and wanted to know how to receive
submitted forms. I’ve looked at CGI and the params tag, but I’m unclear as
to which one should be used.

Any urls and insight appreciated as I can’t find much out there. I’m
confused between the two applications and I can’t seem to get params to work
properly.

I’m building a small app using Sinatra. Here you can see the routes[1] and
the views[2].

The “routes" are composed of two ‘paths’ the ‘get’ and the ‘post’ which
‘redirects’ depending on the situation.

The “views” are made using HAML which is a syntax-sugar for HTML like ERB,
LESS, etc. I’m using CSS but you could use SASS instead if you like it...

NOTE: I’m using an MVC architecture (also called modular) Sinatra which you
can see here: GitHub - atmosx/pritory: Price tracking application for small businesses. based on riblits[3]
skeleton.

If you need more details feel free to ask.

Cheers

[1] pritory/routes/add_product.rb at master · atmosx/pritory · GitHub
[2] pritory/views/add_product.haml at master · atmosx/pritory · GitHub
[3] GitHub - Phrogz/riblits: Shell for new Sinatra Applications

Panagiotis (atmosx) Atmatzidis

email: atma@convalesco.org
URL: http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

"As you set out for Ithaca, hope the voyage is a long one, full of
adventure, full of discovery [...]" - C. P. Cavafy

Hi there. Thanks for the reply.

Yeah the whole Sinatra thing I have working. It’s the submission of forms which got me. I’m reading about ARGV and params, and I was having trouble getting around the latter. I will be taking a look at your Ruby though. It seems you’re just searching through params, so that’s essentially what I was looking for. I need more testing.

Cheers

···

On Dec 13, 2014, at 1:42 PM, Panagiotis Atmatzidis <atma@convalesco.org> wrote:

I’m building a small app using Sinatra. Here you can see the routes[1] and the views[2].

The “routes" are composed of two ‘paths’ the ‘get’ and the ‘post’ which ‘redirects’ depending on the situation.

The “views” are made using HAML which is a syntax-sugar for HTML like ERB, LESS, etc. I’m using CSS but you could use SASS instead if you like it...

NOTE: I’m using an MVC architecture (also called modular) Sinatra which you can see here: GitHub - atmosx/pritory: Price tracking application for small businesses. based on riblits[3] skeleton.

If you need more details feel free to ask.

Cheers

[1] pritory/routes/add_product.rb at master · atmosx/pritory · GitHub
[2] pritory/views/add_product.haml at master · atmosx/pritory · GitHub
[3] GitHub - Phrogz/riblits: Shell for new Sinatra Applications

Panagiotis (atmosx) Atmatzidis