Solved

text_field_for  easy one

Posted on 2008-10-06
2
306 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now