Rails syntax help

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

A Simple Form

<%= start_form_tag(:action => "show_formdata") %>

Text Field: <%= text_field_tag("name", "Aneesha") %>

Drop-down Selection Box: <% languages = ["Ruby", "Java", "C#"].map do |lang| "#{lang}"end.to_s %>

<%= select_tag(“prog_languages[]”, languages, :multiple => “true”)
%>

Checkboxes: <%= check_box_tag("operating_systems[]", "Windows") %>Windows <%= check_box_tag("operating_systems[]", "Linux") %>Linux <%= check_box_tag("operating_systems[]", "Mac") %>Mac

<%= submit_tag("Submit Form") %> <%= end_form_tag %>

On Sep 29, 1:53 am, foxpro [email protected] 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| “#{lang}</
option>” }.to_s %>

You’re also following some very old examples - at least 2 years old.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs