# Collecting data from forms

**URL:** <https://www.ruby-forum.com/t/collecting-data-from-forms/89908>\
**Category:** Rails\
**Created:** [March 29, 2006, 1:27pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908 "2006-03-29T13:27:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [March 29, 2006, 1:27pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908/1 "2006-03-29T13:27:52Z")

</div>

Hi,

I´m having some problems collecting the content of some forms.

This is whats in list.rhtml:

\<%= form\_tag :action =\> ‘send\_message’ %\>  
From:  
\<%= text\_field ‘message’, ‘from’%\>  
  
Message:  
\<%= text\_area ‘message’, ‘text’, :rows =\> 6 %\>

the controller:

def send\_message  
from = (params[:from])  
message = (params[:message])  
puts “From field: = #{from}”  
puts “Message field = #{message}”

system(“echo #{from} \> /tmp/echo-say”)  
system(“echo #{message} \>\> /tmp/echo-say”)  
end

How can I transform the content from the form to a variable so that I  
can use it in a system() command ?

Best regards,  
Martin S.

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [March 29, 2006, 1:35pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908/2 "2006-03-29T13:35:27Z")

</div>

Martin S. napisaÅ?(a):

> Message:  
> the controller:
> 
> How can I transform the content from the form to a variable so that I  
> can use it in a system() command ?
> 
> Best regards,  
> Martin S.

from = (params[:message][:from])  
message = (params[:message][:message])

Peter

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [March 29, 2006, 3:22pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908/3 "2006-03-29T15:22:52Z")

</div>

Hi there,

On Mar 29, 2006, at 1:34 PM, Piotr U. wrote:

> > How can I transform the content from the form to a variable so that I can use it in a system() command ? Best regards, Martin S.
> 
> from = (params[:message][:from])  
> message = (params[:message][:message])

Tried to do a  
puts “the message is from #{from}”  
but is quiet.

What is the right way to print the content?

This is how the controller looks like now:

def send\_message  
from = (params[:message][:from])  
text = (params[:message][:text])

puts “from: #{from}” # says nothing.  
puts “message: #{message}” # empty here as well.

system(“echo #{from} \> /tmp/echo-say”) # …and here.

end

It would really save my day, if someone could show me how to do this  
correctly!

Best regards,  
Martin S.

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [March 29, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908/4 "2006-03-29T15:56:24Z")

</div>

Hi,

On Mar 29, 2006, at 3:21 PM, Martin S. wrote:

> > > end
> 
> but is quiet.  
> puts “from: #{from}” # says nothing.  
> puts “message: #{message}” # empty here as well.
> 
> system(“echo #{from} \> /tmp/echo-say”) # …and here.
> 
> end
> 
> It would really save my day, if someone could show me how to do  
> this correctly!

I got it working, did a s/{from}/{@from}/g 🙂

Thanks for all help!

Regards,  
Martin S.

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [March 29, 2006, 4:23pm UTC](https://www.ruby-forum.com/t/collecting-data-from-forms/89908/5 "2006-03-29T16:23:51Z")

</div>

Hi Martin,

I’m still real new to RoR so take this with a grain of salt…

In general, the result of the processing that takes place in a  
controller  
action is rendered (i.e., output) in a view with the same name as the  
action. You’re trying to produce output in the controller. I don’t  
know  
enough to say for sure that that won’t work. But if I were sitting in  
the  
next cubicle and you hollered over “hey bill, my ‘send\_message’ action  
isn’t rendering like I expect it to”, I’d ask… “what does your  
‘send\_message’ view look like?”

HTH,  
Bill

----- Original Message -----  
From: “Martin S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: 2006-03-29 7:21 AM  
Subject: Re: [Rails] Re: Collecting data from forms

Hi there,

On Mar 29, 2006, at 1:34 PM, Piotr U. wrote:

> > How can I transform the content from the form to a variable so that I can use it in a system() command ? Best regards, Martin S.
> 
> from = (params[:message][:from])  
> message = (params[:message][:message])

Tried to do a  
puts “the message is from #{from}”  
but is quiet.

What is the right way to print the content?

This is how the controller looks like now:

def send\_message  
from = (params[:message][:from])  
text = (params[:message][:text])

puts “from: #{from}” # says nothing.  
puts “message: #{message}” # empty here as well.

system(“echo #{from} \> /tmp/echo-say”) # …and here.

end

It would really save my day, if someone could show me how to do this  
correctly!

Best regards,  
Martin S.

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
