whatman75 (owner)

Revisions

gist: 37724 Download_button fork
public
Public Clone URL: git://gist.github.com/37724.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 %>