Custom methods unacessible in Rails Model -


when try to:

class construction < activerecord::base   def columns     ["a", "b"]   end      store :dados, accessors: columns end 

i get:

undefined local variable or method `columns' #<class:0x007f891037dac0> 

so, how should this?

ps: have tried putting 'self.' before columns , didn't work.

edit — more info problem:

i have set series of serialized hash data stored on column "dados". method store , set attribute acessors. have erased other parts of code not inherent problem, basically, need inform accesors attribute through method instead of declaring directly there. reason because i'll reuse method generate columns.

i wont using method in instance variables, instead inside model itself. code reusing

when create method on model, every instance of model has methods, example if this:

in controller:

@construction=construction.first  @construction.columns // return array; 

can give me more info on need done can better

mmm im still having trouble understanding issue maybe should after create method, this:

class construction < activerecord::base   after_create :something    def columns     ["a", "b"]   end       private   def       store :dados, accessors: self.columns   end end 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -