I repeat this code many times. The only thing that changes is the name in conditions.
find(:all, :conditions => {:name => 'hans'}, :group => 'dato').map(&:klik)
I am trying to make some class method in the model. So I can keep it DRY.
I have been trying this and it is not working.
def self.grafdata(name)
find(:all, :conditions => {:name => '(name)'}, :group => 'dato').map(&:klik)
end
ERROR: uninitialized constant ActionView::CompiledTemplates::Lars
I want to be able to write Model.grafdata(Hans), Model.grafdata(Lars)
I would simply add it as a function to your model:
You can then call either of the following: