Skip to content

Instantly share code, notes, and snippets.

@codeschool-courses
Created August 30, 2011 20:28
Show Gist options
  • Save codeschool-courses/1181936 to your computer and use it in GitHub Desktop.
Save codeschool-courses/1181936 to your computer and use it in GitHub Desktop.
Rails for Zombies 2 - Challenge 3-2
class TweetsController < ApplicationController
# GET /tweets/new
# GET /tweets/new.json
def new
@tweet = Tweet.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tweet }
end
end
# POST /tweets
# POST /tweets.json
def create
@tweet = Tweet.new(params[:tweet])
respond_to do |format|
if @tweet.save
format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }
format.json { render json: @tweet, status: :created, location: @tweet }
else
format.html { render action: "new" }
format.json { render json: @tweet.errors, status: :unprocessable_entity }
end
end
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment