Created
December 19, 2008 00:10
-
-
Save cnix/37724 to your computer and use it in GitHub Desktop.
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 < ApplicationController | |
def create | |
@post = Post.new(params[:post]) | |
if @post.save | |
tweet(@post) | |
flash[:notice] = 'Post was successfully created.' | |
redirect_to manage_posts_path | |
else | |
render :action => 'new' | |
end | |
end | |
private | |
def tweet(post) | |
if post.to_twitter? | |
# do stuff | |
end | |
end | |
end | |
class Post < ActiveRecord::Base | |
attr_accessor :to_twitter | |
alias :to_twitter? :to_twitter | |
end | |
# | |
# in the view | |
<%= check_box :post, :to_twitter %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment