Skip to content

Instantly share code, notes, and snippets.

@febuiles
Last active December 19, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save febuiles/5942688 to your computer and use it in GitHub Desktop.
Save febuiles/5942688 to your computer and use it in GitHub Desktop.
class TweetsController < ApplicationController
def new
@tweet = Tweet.new
end
def create
@tweet = current_user.tweets.build(params[:tweet])
if @tweet.save
@tweet.deliver!
redirect_to new_tweet_path, :notice => t(:scheduled_tweet)
else
flash[:error] = @tweet.errors.full_messages.first
render :new
end
end
private
def tweet_params
params.require(:body, :post_at)
end
end
# Error:
# ActiveModel::ForbiddenAttributesError: ActiveModel::ForbiddenAttributesError
# app/controllers/tweets_controller.rb:7:in `create'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment