Solved

text_field_for  easy one

Posted on 2008-10-06
2
307 Views
Last Modified: 2013-11-13
Hi, I'm an experienced .NET web developer trying to get a handle on Rails.  I'm trying to work through this example,  http://www.railshosting.org/#live_searching   but there are a few things I don't understand.  Here's the first post:

<= text_field_tag(:search) %>   What does the (:search) syntax mean exactly.  I'm sure I was looking in the wrong place, but I can't for the life of me find an explanation of what  the difference is (if any, I get the feeling they're the same) between text_field_tag(:search)  and text_field_tag("search")

Thanks!
0
Comment
Question by:ARACK04
2 Comments
 
LVL 14

Accepted Solution

by:
wesgarrison earned 500 total points
ID: 22652621
:search is a Symbol.  'search' is a String.

Here's the rdoc for Symbol:
http://www.ruby-doc.org/core/classes/Symbol.html

Check out that method:
http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html#M001733

Inside that method, it converts the symbol to a string.  It just looks cleaner and it's easier to type.

Rails uses Symbols for named parameters a lot, a la:
 :conditions => 'true', :order => 'desc', ...

Like, named parameters in a way.
0
 

Author Comment

by:ARACK04
ID: 22652913
Thanks, that was a huge help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
in ruby, how can I call notepad ? 4 549
compare two windows registry keys in chef 1 82
searching using regular expressions 6 151
Ruby or Python 7 62
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question