# Rails

**URL:** <https://www.ruby-forum.com/t/rails/172755>\
**Category:** Ruby\
**Created:** [July 27, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/rails/172755 "2009-07-27T16:26:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haris\_BogdanoviS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a8b319/32.png) [@Haris\_BogdanoviS\_S](https://www.ruby-forum.com/u/Haris_BogdanoviS_S)\
**Post date:** [July 27, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/rails/172755/1 "2009-07-27T16:26:42Z")

</div>

Could someone explain to me:

class Movie \<\< ActiveRecord::Base  
has\_many :Actors  
end

How can I call a method within class definition ? This is not Ruby  
anymore.  
And this : semicolon stands for symbol. Never heard of symbols in Ruby.

---

<div class="post-metadata">

**Author:** ![Haris\_BogdanoviS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a8b319/32.png) [@Haris\_BogdanoviS\_S](https://www.ruby-forum.com/u/Haris_BogdanoviS_S)\
**Post date:** [July 27, 2009, 4:37pm UTC](https://www.ruby-forum.com/t/rails/172755/2 "2009-07-27T16:37:14Z")

</div>

On Mon, Jul 27, 2009 at 4:25 PM, Haris BogdanoviÄ‡[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Could someone explain to me:
> 
> class Movie \<\< ActiveRecord::Base  
> Â Â has\_many :Actors  
> end
> 
> How can I call a method within class definition ? This is not Ruby anymore.

In fact it is. A method call without an explicit receiver goes to  
whatever object happens to be “self”. Inside a class definition, self  
is the class object, in this case Movie (which is an instance of class  
Class). Remember than in Ruby classes are objects too. Check this, for  
example:

irb(main):001:0\> class Base  
irb(main):002:1\> def self.has\_many(thing)  
irb(main):003:2\> puts “I have many #{thing}”  
irb(main):004:2\> end  
irb(main):005:1\> end  
=\> nil  
irb(main):006:0\> class Movie \< Base  
irb(main):007:1\> has\_many :Actors  
irb(main):008:1\> end  
I have many Actors  
=\> nil

> And this : semicolon stands for symbol. Never heard of symbols in Ruby.

[http://onestepback.org/index.cgi/Tech/Ruby/SymbolsAreNotImmutableStrings.red](http://onestepback.org/index.cgi/Tech/Ruby/SymbolsAreNotImmutableStrings.red)

Check here for example for some explanations of symbols, although with  
1.9 I believe they have become more string-like than in 1.8

Hope this helps,

Jesus.
