RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: Bodacious
Site: www.gavinmorrice.com
Understood - would be good to see more on Metal though :)
Particularly, the common pitfalls when trying to include behaviour that may be strewn across two or three ActionController modules
I just discovered RABL - me gusta!
Great idea and well presented as usual Ryan...
Title was a little misleading though :/
I've having a problem with this too - did you ever solve this?
You're totally right / I completely overlooked the two arguments making my solution wrong.
Generally, I don't like the "class goes in, instance comes out" approach but I think it's fine in this case
Suggested refactor:
module ApplicationHelper def present(object, presenter = "#{object.class}Presenter".constantize.new ) yield presenter if block_given? presenter end end
It's better to pass an instance as a parameter than a class
<% present @user, UserPresenter.new do %> <!--- stuff --> <% end %> <!-- or --> <% present @user do %> <!--- stuff --> <% end %>
I'd +1 that
My favourite ruby book of all time is Metaprogramming Ruby
The thing I loved most about this book is that BDD is part of every example. I always feel that by showing just the code, you're only showing half of the solution to a problem?
Understood - would be good to see more on Metal though :)
Particularly, the common pitfalls when trying to include behaviour that may be strewn across two or three ActionController modules
I just discovered RABL - me gusta!
Great idea and well presented as usual Ryan...
Title was a little misleading though :/
I've having a problem with this too - did you ever solve this?
You're totally right / I completely overlooked the two arguments making my solution wrong.
Generally, I don't like the "class goes in, instance comes out" approach but I think it's fine in this case
Suggested refactor:
It's better to pass an instance as a parameter than a class
I'd +1 that
My favourite ruby book of all time is Metaprogramming Ruby
The thing I loved most about this book is that BDD is part of every example. I always feel that by showing just the code, you're only showing half of the solution to a problem?