robhanlon22 / decorates_before_rendering Goto Github PK
View Code? Open in Web Editor NEWunmaintained
License: MIT License
unmaintained
License: MIT License
It seems like supporting plural objects (for instance in Controller#index) is a bit more difficult that necessary.
Is there a reason your code isn't using Model#decorate
? I just started using Draper this evening, so I'm still stumbling my way around, but it appears that I can call decorate
on my model objects (in 0.18.0 it's in Draper::ModelSupport
, and in the beta releases it looks to be in Draper::ModelSupport
. I can even do Model.where(condition).decorate
, and it creates a DecoratedEnumerableProxy
for the collection.
It seems like you should be able to dramatically simplify the code so all it has to do is see if the object supports decorate
and if so then call it!
An then you can close the gem if you feel it is obsolete...
I'm trying to install DecoratesBeforeRendering
gem but get an error uninitialized constant ApplicationController::DecoratesBeforeRendering
while include (DecoratesBeforeRendering
or ::DecoratesBeforeRendering
) in a controller. Gem is present in my Gemfile.lock
. Why an error has occurred?
IMO, using instance vars is a "bad hack", back from the dirty hacking days of 2005-2008. The good style is to instead expose public methods to the view that return the object(s) in question.
See fx https://github.com/hudge/proffer https://github.com/voxdolo/decent_exposure and several other similar gems trying to patch this anti-pattern...
See also: http://elia.schito.me/tagged/instance-variables
Would be nice with an extension of this gem to allow for a more modern approach :)
Cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.