Skip to content

Instantly share code, notes, and snippets.

@justinko
Created February 26, 2012 13:37
Show Gist options
  • Save justinko/1916757 to your computer and use it in GitHub Desktop.
Save justinko/1916757 to your computer and use it in GitHub Desktop.
No instance variables in Rails controllers
class PostsController < ActiveRecord::Base
helper_method :posts, :post
def index; end
def create
if post.save
end
end
private
def posts
@posts ||= Post.all
end
def post
@post ||= Post.new(params[:post] || {})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment