Skip to content

Instantly share code, notes, and snippets.

@flarnie
Last active December 21, 2015 01:08
Show Gist options
  • Save flarnie/6225165 to your computer and use it in GitHub Desktop.
Save flarnie/6225165 to your computer and use it in GitHub Desktop.
Testing the behavior of 'Flash' in a userscontroller for Ruby on Rails 3.2.0.
class UsersController < ApplicationController
def new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] ="OLD VALUE assigned in 'create'"
redirect_to user_url(@user)
else
flash[:notice] = "Failed to save user!"
redirect_to new_user_url
end
end
def index
@users = User.all
end
def show
flash[:notice] = "NEW VALUE assigned in 'show'"
@user = User.find(params[:id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment