Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationDecorator class #727

Closed
dmitrypol opened this issue Feb 26, 2016 · 9 comments
Closed

ApplicationDecorator class #727

dmitrypol opened this issue Feb 26, 2016 · 9 comments
Milestone

Comments

@dmitrypol
Copy link

A common pattern in Rails is to have ApplicationController, ApplicationMailer, etc. The class inherits from base and developer generated code inherits from it. This provides a useful place to implement common functionality.

We are manually introducing this in our app it but it could be a built-in feature. Does anyone have ideas / suggestions?

class ApplicationDecorator < Draper::Decorator
  delegate_all
  ...
end
class UserDecorator < ApplicationDecorator
  ...
end
@anbiniyar
Copy link

I did the same thing as well. +1

@Mehonoshin
Copy link

Nice idea!

@francirp
Copy link

francirp commented Aug 8, 2016

👍 I do the same thing. I typically implement currency and percent class methods in my BaseDecorator. If you're curious I wrote a post on it here: https://medium.com/@ryan_p_francis/how-decorators-saved-my-rails-app-c5cc18ef7d2e

@akodkod
Copy link
Collaborator

akodkod commented Aug 8, 2016

Yeap, good idea! We could create rake task rake draper:install to create this file automatically.

@francirp
Copy link

francirp commented Aug 8, 2016

Yeah exactly. Happy to take a first punch at a PR for this if it's something the team wants to pursue. Who makes decisions like this on the Draper team? @seanlinsley what are your thoughts on the subject?

@seanlinsley
Copy link
Member

👍 sounds like a good idea

@codebycliff
Copy link
Collaborator

This seems like a good idea. Is anyone still interested in taking a stab at a PR?

@chuck-john
Copy link
Contributor

@codebycliff, this is a great idea. I'll get a branch started.

@codebycliff
Copy link
Collaborator

This was merged in #796.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants