Created
February 26, 2012 13:37
-
-
Save justinko/1916757 to your computer and use it in GitHub Desktop.
No instance variables in Rails controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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