[Boulder-Denver Ruby Group] re-inventing components
David Clements
david at collectiveintellect.com
Fri May 18 21:24:08 EDT 2007
Not sure if I am totally following the issue here. I totally agree
with the premise that the support for widgetizing our apps is really
ugly. And I use components regularly to widgetize various portions of
our apps.
Are we talking about syntax or functionality?
We could re-write your example today using render_component_as_string:
class FooController < ApplicationController
def bar
# get a handle on, and parameterize, a bar controller
bar_controller = component_for(:controller => 'bar') do
@foo = 42
@bar = 'forty-two'
end
# call two actions on the bar controller, potentially reusing
the entire model+view+controller stack
foo = bar_controller.content_for :action => 'foo'
bar = bar_controller.content_for :action => 'bar'
render :text => [foo, bar].inspect #=> [42, "forty-two"]
end
end
With this:
class FooController < ApplicationController
def bar
params_hash = {:foo => 42, :bar => 'forty_two'}
# call two actions on the bar controller, potentially reusing
the entire model+view+controller stack
foo = render_component_as_string( params_hash.merge(:controller
=> "bar", :action => "foo" )
bar = render_component_as_string( params_hash.merge(:controller
=> "bar", :action => "bar" )
render :text => [foo, bar].inspect #=> [42, "forty-two"]
end
end
Not sure if I am missing something, as I didn't here Bruce's talk
last week,
Dave
On May 18, 2007, at 4:41 PM, Peter Jones wrote:
ara.t.howard wrote the following on Fri, May 18, 2007 at 02:16:54PM
-0600:
> i'd love feedback from the community
Ara, this stuff looks pretty good. Like you, I tend to gravitate
towards OOP,
and it's disappointing that with Rails, MVC is only 1/3 OO. I'm
wondering if
it's time to rethink ActionController and ActionView a bit.
--
Peter Jones - 303-669-2637
pmade inc. - http://pmade.com
_______________________________________________
Bdrg-members mailing list
Bdrg-members at rubyforge.org
http://rubyforge.org/mailman/listinfo/bdrg-members
More information about the Bdrg-members
mailing list