A
A
Alexander Grishin2016-01-28 19:17:51
Ruby on Rails
Alexander Grishin, 2016-01-28 19:17:51

Is it legal to initialize a class object variable in the initialize method?

Can it be done like this:

def initialize 
   super 
   @variable = Catalog.all
end

Or is it done differently in RoR?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Beloshitsky, 2016-01-28
@mbeloshitsky

Why not just

class Blah
  @@variable = Catalog.all
end

?

E
Evgeniy Trebin, 2016-01-28
@evgeniy_trebin

Sure, why not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question