render_component alternative
in routes.rb i have put:
map.connect '/:alias', :controller => 'cores' ,:action=>"view"
this alias is connect with 3 models: event place and artist in my cores controller i used render_component for rendering the action relative to the model.
if(core = Core.find(:first, :conditions => ["alias = ?", params[:alias]]))
type = core.class.to_s.downcase
render_component(:controller => type,
:action => "view",
:id => core.id.to_s,
:params => params)
end
In rails 2.3 render_component is deprecated. But what's the solution for do this?
I'v开发者_开发知识库e seen that there is a plugin for reuse the render_component but i want know the other solution.
thanks.
The only solution is to redesign your architecture in order to avoid components.
I have to maintain an application based on components and I have to say this is a real nightmare. I recently upgraded the app to Rails 2.3 and I'm really looking forward to kill the component integration as soon as possible.
If you decide to go ahead with components, keep in mind the existing plugin doesn't work with Rails 2.3. You should make some changes in order to get it working.
There is another partial solution.
I'm looking after a Rails app in "hospice" mode, so whilst the right answer is definitely to redesign to avoid components, I needed to support render_component, while at the same time upgrading to Rails 2.3.
A temporary solution is to install the render_component plugin:
script/plugin install git://github.com/lackac/render_component.git -r rails-edge
You must have the git client installed on your server for this install to work; if not you'll get a silent failure.
精彩评论