Skip to content

Instantly share code, notes, and snippets.

@m4tm4t
Created December 15, 2012 13:58
Show Gist options
  • Save m4tm4t/4295253 to your computer and use it in GitHub Desktop.
Save m4tm4t/4295253 to your computer and use it in GitHub Desktop.
class DemoController < ApplicationController
before_filter :define_some_variables, only: [:index, :hello]
def index
# Renders the action it would render if it were the "hello" action.
# render({:action => 'hello'}) # This is the old way, Rails 1.x.
# Specifies the template to render.
render({:tamplate => 'demo/hello'})
# Rails 3.x.
#render('demo/index')
# Rails knows we are in 'demo' becase we are in "DemoController".
#render('index')
# redirect_to(:controller => 'demo', :action => 'other_hello')
end
def hello
# redirect_to('http://jeditux.wordpress.com')
@id = params[:id].to_i
@page = params[:page].to_i
end
def other_hello
render(:text => 'This is plain text bein rendered.')
end
def test
# render({:text => 'More plain text being rendere...'})
#render({:action => 'index'})
end
private
def define_some_variables
@arr = [1, 2, 3, 4, 5]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment