Forum: Ruby on Rails Localization using inheritance

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jakov (Guest)
on 2006-12-28 17:28
Hi!

 I'm trying to implement localization using inheritance, i.e.:

class ParentController < ApplicationController

  layout "mylayout"

  def initialize
    #do something
  end

  def index
    #do something
  end

  def search
    #do something
  end

  # ...

end

Controller do his job and render page using "mylayout" and views from
"/view/parent" folder. After that, I implemented another controller:

class ChildController < ParentController

  layout "mylayout"

  def initialize
    super
    #optionally do something more
  end

  def index
    super
    #optionally do something more
    render :template => "parent/index"
  end

  def search
    super
    #optionally do something more
    render :template => "parent/search"
  end

  # ...

end


 This method works fine. Since I only have few things that need to be
shown differently, in child controller I change and/or add them and I
get just what I wanted. However, for every method I used in
ParentController I must have one in ChildController which says what view
to use for rendering (since both controllers work with same views). My
question is: is there a way to tell Rails that my ChildControllers views
are those in "/view/parent" folder, so that I don't have to implement
methods that only have
  super
  render :template => "parent/..."
lines?

Thanks in advance!
This topic is locked and can not be replied to.