Search code examples
ruby-on-railsruby-on-rails-2

Raw output from controller action method


I want to output some text without using a template. Right now I have a controller action method that's altering the Content-Type of the response and I want to display the text directly, without creating a template file (a single-line template file is useless).


Solution

  • You can use render :text in Rails 2.3:

    You can send plain text – with no markup at all – back to the browser by using the :text option to render [...]

    So this:

    render :text => 'whatever'
    

    should do what you want.

    The same thing works in Rails 3.