Whats the difference between symbol and string?

Answer Posted / surekha matte

Rails makes extensive use of symbols. A symbol looks like a
variable symbols name, but it’s prefixed with a colon.
Examples of symbols include :action,:line_items, and :id.

Rails uses symbols to identify things. In particular, it
uses them as keys when naming method parameters and looking
things up in hashes. For example:
redirect_to :action => "edit", :id => params[:id]

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between gem and plugin?

537


what are the positive aspects of Rails?

457


Choosing between belongs_to and has_one?

480


What is the purpose of load, auto_load, and require_relative in ruby ?

451


What is object-relationship-model (orm)?

515






Explain Get and post method?

512


What is the role of mvc architecture in ruby on rails?

465


How do rails implement ajax?

493


Which command is used to create a migration?

494


Explain model in rails?

470


Explain valid and invalid in rails?

473


What do you mean by render and redirect_to?

485


What are the various changes between the rails version 2 and 3?

447


difference between member routes and collection routes ?

529


Tell me what is rails active record in ruby on rails?

437