Questions tagged [draper]

Decorators/View-Models for Rails Applications

Draper is a gem that adds an object-oriented layer of presentation logic to your application.

Without Draper, this functionality might have been tangled up in procedural helpers or adding bulk to your models. With Draper decorators, you can wrap your models with presentation-related logic to organise - and test - this layer of your app much more effectively.

84 questions
0
votes
0 answers

New way of seeing allowed methods with Draper?

I recently upgraded the Draper gem to 1.2.1. I was previously checking to see what fields were allowed via: class MyDecorator < Draper::Decorator allows :email end ...spec... MyDecorator.allowed.should == [:email] Apparently "allows" is now…
Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
0
votes
1 answer

Decorate relation object in a parent objects view partial

I'm using Draper to decorate my objects. I have a model 'starts' that has_one horse. I have a horse decorator that has a boy_or_girl method that I have refactored form the horse mode. #{start.horse.boy_or_girl}" I'm getting a method not found on…
Will
  • 4,498
  • 2
  • 38
  • 65
0
votes
2 answers

How to include draper decorator in associated objects

I am using Draper to add decorators to several models, I have some decorators for one model (my documents model) that I want to use to "decorate" another model (my user model). How can I do this? I have tried putting this in my documents decorator…
Jeremy Lynch
  • 6,780
  • 3
  • 52
  • 63
0
votes
1 answer

Unable to run the rails generator for Draper

I'm on Ruby 1.9.3 and Rails 3.0.11. I recently installed Draper(0.12.0) gem, but I'm unable to run its generators. I get the following error when I try to run the generator on the Post model :- rails generate decorator…
boddhisattva
  • 6,908
  • 11
  • 48
  • 72
0
votes
2 answers

Stubbing a Presenter model doesn't work

I have a presenter: class MyPresenter < Decorator . . . def items . . . end # a method being tested which uses the above method def saved_items items.reject { |m| m.new_record? } end end and its test: describe MyPresenter…
Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113
0
votes
2 answers

How to include Draper Decorators in Rails Console?

I'd like to see the output of some of my Draper Decorators in Rails console (https://github.com/drapergem/draper and http://railscasts.com/episodes/286-draper). To do so, I was looking for a way to include a decorator and its methods similar to as…
jay
  • 12,066
  • 16
  • 64
  • 103
0
votes
1 answer

How to loop through association with a Draper decorator method?

I have a TripDecorator which decorates a Trip object. A Trip has many Activities. I'd like to create a TripDecorator method that generates a list of activities belonging to a specific Trip. How can I convert this:
Activities
    <%…
kevinwmerritt
  • 2,218
  • 1
  • 15
  • 12
0
votes
1 answer

Rails 3: draper gem decorating STI models

I have STI model #a/m/document.rb class Document < ActiveRecord::Base end #a/m/document/static.rb class Document::Static < Document end #a/m/document/dynamic.rb class Document::Dynamic < Document end I'm using draper gem to decorate my model #…
equivalent8
  • 13,754
  • 8
  • 81
  • 109
0
votes
1 answer

Rails + jQuery-tokeninput + Draper decorator method

I'm using Rails + jQuery-tokeninput to perform typeahead search and populate a "belongs_to" relationship. Here is the model: class Performance < ActiveRecord::Base attr_accessible :composition_tokens belongs_to :composition ... …
mpelzsherman
  • 707
  • 9
  • 9
1 2 3 4 5
6