Forum: Ruby on Rails Collecting data from forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3b1daae9f655c5dba51ff1cdf03f1bef?d=identicon&s=25 Martin Stabenfeldt (Guest)
on 2006-03-29 13:27
(Received via mailing list)
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'%>
<br>Message:
<%= text_area	'message', 'text', :rows => 6 %>

<tr>
   <td></td>
   <td><input type="submit" value=" Send the message! " /></td>
</tr>




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 Stabenfeldt
Dcbf676f860477e44b275cae5d6318a4?d=identicon&s=25 Piotr Usewicz (lopmx)
on 2006-03-29 13:35
(Received via mailing list)
Martin Stabenfeldt napisaÅ?(a):
> <br>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 Stabenfeldt

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

Peter
3b1daae9f655c5dba51ff1cdf03f1bef?d=identicon&s=25 Martin Stabenfeldt (Guest)
on 2006-03-29 15:22
(Received via mailing list)
Hi there,

On Mar 29, 2006, at 1:34 PM, Piotr Usewicz wrote:
>>   <td><input type="submit" value=" Send the message! " /></td>
>> 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 Stabenfeldt
>
> 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 Stabenfeldt
3b1daae9f655c5dba51ff1cdf03f1bef?d=identicon&s=25 Martin Stabenfeldt (Guest)
on 2006-03-29 15:56
(Received via mailing list)
Hi,

On Mar 29, 2006, at 3:21 PM, Martin Stabenfeldt wrote:
>>>   <td></td>
>>> 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 Stabenfeldt
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2006-03-29 16:23
(Received via mailing list)
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 Stabenfeldt" <martin@stabenfeldt.net>
To: <rails@lists.rubyonrails.org>
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 Usewicz wrote:
>>   <td><input type="submit" value=" Send the message! " /></td>
>> 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 Stabenfeldt
>
> 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 Stabenfeldt


_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
This topic is locked and can not be replied to.