mardi 1 décembre 2015

Call class from /lib into rabl

I have a class called "Person" in my rails app /lib directory.

module Backend
  class Person
    attr_accessor :id

    def initialize(attr = {})
         :
    end

    def some_method
      :
    end
  end
end

The question is how can I call this class in my rabl file? Is it possible to call it in my rabl file? I tried:

require 'backend/person'
object @person
   :
   :
   :
node(:my_element) { |person| Backend::Person.new(id: person.id).some_method }

But it does not work for me.

Aucun commentaire:

Enregistrer un commentaire