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
Martin Stabenfeldt napisa?(a):> 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 Stabenfeldtfrom = (params[:message][:from]) message = (params[:message][:message]) Peter
Hi there, On Mar 29, 2006, at 1:34 PM, Piotr Usewicz wrote:> Martin Stabenfeldt asked: >> 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 > > 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
Hi, On Mar 29, 2006, at 3:21 PM, Martin Stabenfeldt wrote:> On Mar 29, 2006, at 1:34 PM, Piotr Usewicz wrote: >> Martin Stabenfeldt asked: >>> 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 >> >> 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!I got it working, did a s/{from}/{@from}/g :-) Thanks for all help! Regards, Martin Stabenfeldt
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:> Martin Stabenfeldt asked: >> 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 > > 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