开发者

Render correct action within parent controller when using inheritance hierarchy - Rails

I am working with a code base that has this single table inheritance hierarchy:

BlogEntryWizardController < BlogEntriesController < CommonEntryController < ApplicationController

BlogEntryWizardController (BEWC) uses the same model that BlogEntriesController (BEC) uses. The only real difference between the BEWC and the BEC is the views (one is just a tutorial wizard of the other). Upon submitting the form within the wizard, it keeps taking the user to the "show" action of the BEC, the parent. This occurs within CommonEntryController (CEC):

fo开发者_运维百科rmat.html {
  render(:action => 'show')
}

This invokes the show method of the BEC, but I need it to invoke the overriden show method within the BEWC. Is there a way of distinguishing within CE which "show" action to call appropriately?

Thanks for your two cents.


Inside of the "show" action within BEC, send the redirect to the show controller:

redirect_to :controller => "BEWC", :action => "show"

Doing just that isn't enough as instance variables aren't persistent between controllers. So you can save your BEC instance variable within a session and retrieve it within your BEWC contoller in your "show" action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜