views:

13

answers:

2

Is there a way to tell an entire controller to render a particular partial or text?

Example:

class PageNotesController < ApplicationController
  render :text => "Testing"
  def index
    @notes = PageNotes.all
  end

  def show
    @note = PageNotes.find(params[:id])
  end

  def create
    @note = PageNotes.create(params[:note])
  end

end

Now obviously I can go into each individual method and tell it to render something, but I was just curious to know if this is possible.

Thanks in advance!

A: 

You could do this. I'm unsure why you'd want to, but here's how.

class PageNotesController < ApplicationController
  before_filter :write_out_testing

  ...

  protected
  def write_out_testing
    render :text=>"Testing
    false #do not execute the action originally requested.
  end

end
Jesse Wolgamott
A: 

you can tell an entire controller to render a layout.

layout 'some_layout'

if you want a controller to render the same action then you can create one action and pass it different options and find results by params conditions.

to explicitly answer your question. I don't know.

Sam
Thanks! This seems to be the best solution to my problem
dennismonsewicz