Can 2 actions use a single view?

I have 2 different actions, when they are complete, can they both be
sent to the same view?

would i use a Partial Page Template ?

On 11/20/06, holly [email protected] wrote:

I have 2 different actions, when they are complete, can they both be
sent to the same view?

Check out ‘redirect_to’ and ‘render’ in the Rails API docs.

unknown wrote:

On 11/20/06, holly [email protected] wrote:

I have 2 different actions, when they are complete, can they both be
sent to the same view?

Check out ‘redirect_to’ and ‘render’ in the Rails API docs.

Controller.rb

def myaction1
.
.
.
render :template => ‘yourview’
end

def myaction2



render :template => ‘yourview’
end

hth…

thankyou

On 11/20/06, holly [email protected] wrote:

would i use a Partial Page Template ?

Well a partial is really just a way to keep your views tidy by not
repeating the same chunk of code across different views. So partials
are largely about the ‘view’ end of things whereas your initial query
re 2 different actions using the same view relates more to the
controller side of things.

Partials come into play as a way of keeping things DRY - so if you had
a User model and an Address model, and a User has_many addresses,
there might be more than one place in your application where you want
to display a list of a user’s addresses.

Rather than repeat the code that iterates through the array of a
user’s addresses, you would extract this as a partial and then render
that partial in any view where you wanted to display the list.

So a partial is just that - a ‘partial’ view, whereas your initial
question seemed to imply that you wanted 2 controller actions to
render the exact same view.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs