Collecting data from forms


#1

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.


#2

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


#3

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.


#4

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 :slight_smile:

Thanks for all help!

Regards,
Martin S.


#5

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
To: 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