Question: I understand that symbols and strings are not same, but I don't understand the concept of symbols.

As I understand, a symbol refers to something else. I use the word refer here for my better understanding, not in the in sense of C/C++ pointers or references.

1. When I create a new controller in Rails, using something like `rails g controller Posts`, does Ruby automatically create a new symbol `:posts`, which refers to the `Posts` controller? Is this `:posts` symbol globally accessed from anywhere in the application? Only in that case, I can understand a construct like:

```
resources :posts

```

which Ruby can translate for itself: "Ok, I know that `:posts` refers to `posts_controller`, so I need to create CRUD routes for that controller". Am I right?

1. What roles do symbols `:title` and `:content` have in this example? I assume that `form.label` is equivalent to `form.label(:title)`.

```
<%= form_for @post, :html => {:class => "new_post"} do |form| %>
<%= form.label :title %><br>
<%= form.text_field :title %><br>

<%= form.label :content %><br>
<%= form.text_area :content %><br>

<%= form.submit("Add new post") %>

```
2. Are there built-in symbols like `:all` and symbols that are created on-the-way? When I say on-the-way, as I can see when I create some method like:

```
def something
    ...
end

```

Does Ruby create a new symbol `:something`, which will refer to method `something`? If that is correct, why do I need that symbol, where can I can use it?

```
@posts = Post.all #Or Post.all() => Standard OOP approach, i know what happens here
@posts1 = Post.find(:all) # Dont know what happens here

```

What about `@posts1`, what am I doing here? What do `:all` mean here? Is it some constant value (not string) for Ruby to know that it must pull every `Post` from DB?

Answer: 
A `Symbol` in Ruby is just an immutable string with a special syntax. It's used mostly so you can use less memory when doing string matching like operations as in:

```
options = { :me => 'joe' }
puts options[:me]

```

This creates a single symbol for `:me`, if you used strings:

```
options = { 'me' => 'joe' }
puts options['me']

```

Two strings would have been created, since strings in Ruby are mutable. So, no, there's no special meaning and it's not *something that refer on something other*, it's mostly a hack to the fact that strings in Ruby are mutable by default.

As for your last question, :all is just a value that the method implements in something like "a == :all ? return everything : so something else". It's just a method parameter.
Symbol is just an immutable interned string meaning that all symbol variables with the same value point to exactly the same memory location. They also never garbage collected so avoid creating them with `to_sym`. They are frequently used as keys in hash tables but here's the catch - some hash tables you'll receive from external libraries (e.g. API clients) have strings as keys so when you try to get the value as you're used with with `obj[:some_attribute]` you'll get `nil`.