Are views inheritable


#1

Is it possible to use a child model’s controller to impliment it’s
parents view before adding its own output ?

possibly by the use of super ?

_tony


#2

On 06/03/06, Anthony G. removed_email_address@domain.invalid wrote:

Is it possible to use a child model’s controller to impliment it’s
parents view before adding its own output ?
possibly by the use of super ?

Use partials, for example:

File _common.rhtml

Common parts

File parent.rhtml

<%= render :partial => ‘common’ %>

File child.rhtml

<%= render :partial => ‘common’ %>

Let's add some new contents


#3

Use partials, for example:

File _common.rhtml

Common parts

File parent.rhtml

<%= render :partial => ‘common’ %>

File child.rhtml

<%= render :partial => ‘common’ %>

Let's add some new contents

Doesn’t the partial have to be in the model named directory for that to
work ?
ie
views/child/_common.rhtml

whereas I want it to use

views/parent/_common.rhtml

_tony


#4

views/parent/_common.rhtml

_tony

<%= render_partial ‘parent/common’, @user %>

_T


#5

Hi Anthony,

On 06/03/06, Anthony G. removed_email_address@domain.invalid wrote:

Doesn’t the partial have to be in the model named directory for that to
work ?
ie
views/child/_common.rhtml

whereas I want it to use

views/parent/_common.rhtml

It may be anywhere, you just have to provide a proper path:

app/views/

  • parent/
  • _common.rhtml
  • list.rhtml (uses :partial => ‘common’ - local path)
  • child/
  • list.rhtml (uses :partial => ‘/parent/common’ - path from other
    controller)