Template location not default

By default, Rails associates an action with a template having the
same name as the name of the action and residing in a directory with
the same name as the name of the controller.

Is there some way from within the action that I can change this
behavior? I’m thinking that I could probably change it from within
routes.rb; but, I’d really rather do it from within the action so that
when I look at the action code I can clearly see what I did rather
than spending time scratching my head and wondering why my action is
displaying a non-default template.

Thanks for any input.

 ... doug

sure:

render :template => ‘path/to/template’

The path is rooted in /app/views.

-Bill

doug wrote:

Thanks for any input.

 ... doug


Sincerely,

William P.

Thanks, Bill, for the input. So, am I to conclude that
render :template (unlike just plain ‘render’) terminates execution of
the action or do I need to add ‘and return’ to make sure that the
action terminates at that point? Thanks.

   ... doug

If you want to terminate at that point, you will have to add ‘and
return’.

–Bill

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