method

view_context

Importance_2
Ruby on Rails latest stable (v7.1.3.2) - 1 note - Class: AbstractController::Rendering

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.0.2) is shown here.

These similar methods exist in v7.1.3.2:

view_context() public

An instance of a view class. The default view class is ActionView::Base

The view class must have the following methods: View.new[lookup_context, assigns, controller]

Create a new ActionView instance for a controller 

View#render[options]

Returns String with the rendered template 

Override this method in a module to change the default behavior.

Show source
Register or log in to add new notes.
January 8, 2013
1 thank

Helper Methods inside of a Controller

When needing to include a helper method inside of a controller, instead of including the ENTIRE helper module, simply use this method like so:

module ApplicationHelper def fancy_helper(str) str.titleize end end class MyController < ApplicationController def index @title = view_context.fancy_helper "dogs are awesome" end end