On Sep 29, 1:53 am, foxpro
<avazfer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi Guys,
>
> I am very new to Ruby and Rails, am trying to understand the syntax of
> it. I got this code from a book but can''t understand what does
"</
> option>"end.to_s" do. Here is the complete "view"
code. Note: This
> code works fine
>
This is mostly just confusingly formatted. Another way to write it
would be
<% languages = ["Ruby", "Java", "C#"].map {
|lang| "<option>#{lang}</
option>" }.to_s %>
You''re also following some very old examples - at least 2 years old.
Fred> <h2>A Simple Form</h2>
> <%= start_form_tag(:action => "show_formdata") %>
> <p>Text Field:
> <%= text_field_tag("name", "Aneesha")
%></p>
> <p>Drop-down Selection Box:
> <% languages = ["Ruby", "Java", "C#"].map
do |lang|
> "<option>#{lang}</option>"end.to_s %>
>
> <%= select_tag("prog_languages[]", languages, :multiple =>
"true")
> %></p>
> <p>Checkboxes:
> <%= check_box_tag("operating_systems[]", "Windows")
%>Windows
> <%= check_box_tag("operating_systems[]", "Linux")
%>Linux
> <%= check_box_tag("operating_systems[]", "Mac")
%>Mac
>
> </p>
> <%= submit_tag("Submit Form") %>
> <%= end_form_tag %>