to_sym
converts a string to a symbol. For example, "a".to_sym
becomes :a
.
It’s not specific to Rails; vanilla Ruby has it as well.
It looks like in some versions of Ruby, a symbol could be converted to and from a Fixnum as well. But irb
from Ruby 1.9.2-p0, from ruby-lang.org, doesn’t allow that unless you add your own to_sym
method to Fixnum. I’m not sure whether Rails does that, but it doesn’t seem very useful in any case.
Related Posts:
- What does %w(array) mean?
- How to check whether a string contains a substring in Ruby
- Ruby array to string conversion
- How to delete specific characters from a string in Ruby?
- How to convert a string to lower or upper case in Ruby
- What is the canonical way to trim a string in Ruby without creating a new string?
- Get underlined text with Markdown
- What is the meaning of *nix?
- Get underlined text with Markdown
- What does the “map” method do in Ruby?
- How to write a switch statement in Ruby
- Rails 5 ActionController::InvalidAuthenticityToken error
- what does ? ? mean in ruby
- How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite?
- How to use “gets” and “gets.chomp” in Ruby
- Getting a substring in Ruby by x number of chars
- Ruby: How to install a specific version of a ruby gem?
- ruby operator “=~” [duplicate]
- What is attr_accessor in Ruby?
- ActionController::UnknownFormat
- What does ||= (or-equals) mean in Ruby?
- How to read lines of a file in Ruby
- Array to Hash Ruby
- Ruby: undefined method `[]’ for nil:NilClass when trying to get Enumerator on an Array of Hashes
- How to map with index in Ruby?
- Ruby equivalent for Python’s “try”?
- What does “+=” (plus equals) mean?
- Rails 4 RoutingError: No Route Matches
- How to sum array of numbers in Ruby?
- How to check if a value exists in an array in Ruby
- undefined method (NoMethodError) ruby
- Multi-Line Comments in Ruby?
- How to uninstall ruby installed by ruby-install
- PG::ConnectionBad – could not connect to server: Connection refused
- Rails syntax error : unexpected keyword_ensure, expecting end-of-input
- Removing all installed Gems and starting over
- Ruby `send` vs `call` method
- What is the meaning of “do | |” in Ruby?
- RVM is not a function, selecting rubies with ‘rvm use …’ will not work
- Ruby: kind_of? vs. instance_of? vs. is_a?
- Rails: I installed Ruby, now “bundle install” doesn’t work
- How to do a newline in output
- Ruby: What is the easiest way to remove the first element from an array?
- Ruby String to Date Conversion
- p vs puts in Ruby
- Determining type of an object in ruby
- Fizz Buzz in Ruby for dummies
- How to Uninstall RVM? [duplicate]
- What is the “right” way to iterate through an array in Ruby?
- What is the difference between a Process’ pid, ppid, uid, euid, gid and egid?
- Equivalent of “continue” in Ruby
- Difference between map and collect in Ruby?
- Creating and iterating a 2d array in Ruby
- What is the best way to convert an array to a hash in Ruby
- Ruby 2.0.0p0 IRB warning: “DL is deprecated, please use Fiddle”
- Getting error: dyld: Symbol not found: _clock_gettime
- Uninstall old versions of Ruby gems
- Meaning of #{ } in Ruby?
- Uploading a file in Rails
- What is java interface equivalent in Ruby?
- Sort hash by key, return hash in Ruby
- Gem installation error: You have to install development tools first
- How to understand strptime vs. strftime
- How can I delete one element from an array by value
- How to break out from a ruby block?
- ERROR: While executing gem … (Gem::FilePermissionError)
- No such file or directory @ rb_sysopen ruby
- How to add to an existing hash in Ruby
- Ruby ‘require’ error: cannot load such file
- Difference between $stdout and STDOUT in Ruby
- How to count instances of character in SQL Column
- No implicit conversion of String into Integer (TypeError)?
- Multi-Line Comments in Ruby?
- Print string to text file
- Java String Split by “|”
- Array to String PHP?
- What is a “method” in Python?
- How do I append one string to another in Python?
- How do I create an array of strings in C?
- What is use of c_str function In c++
- How do I properly compare strings in C?
- C++ Parsing input string to variables
- Can I multiply strings in Java to repeat sequences?
- Java way to check if a string is palindrome
- Read whole ASCII file into C++ std::string
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- Converting string to Date and DateTime
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- How do I check if string contains substring?
- Data argument not used by format strings in C
- std::wstring VS std::string
- Replacing a character from a certain index
- Removing trailing newline character from fgets() input
- Create nice column output in python
- TypeError: decoding str is not supported
- The difference between char * and char[] [duplicate]
- Python-like list comprehension in Java
- Append a single character to a string or char array in java?
- Unrecognized escape sequence for path string containing backslashes
- Convert JsonObject to String