Solved

text_field_for  easy one

Posted on 2008-10-06
2
304 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
Comment Utility
: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
Comment Utility
Thanks, that was a huge help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

13 Experts available now in Live!

Get 1:1 Help Now