how to add extra data in draper

June 07, 2015

Reading time ~1 minute

If you want to add extra data in draper you can use :context option.

person.rb

class Persion < Draper::Decorator
  is_admin?
    context[:role] == 'admin'
  end
end

then you can pass option for each person object.

person_a = Person.decorate(people[0], context: {role: 'admin'})
  person_b = Person.decorate(people[1], context: {role: 'normal'})

  puts person_a.is_admin? # return true
  puts person_b.is_admin? # return false

add ticket number to git commit automatically

Most of ticket tracker like Github, pivotal tracker have function to connect your commit to ticket(story).But every time when you commit ...… Continue reading

I will build frontend and backend separately

Published on September 28, 2016

order of angular controller's initialisation

Published on October 05, 2015