I learned last night the flash variable in Rails. It is a special variable that stores data temporarily.
My group at flatiron school is building an application this week and I was assigned the task to research on how to build a signup/signin functionality. The Rails flash would show the user a welcome message as soon as he/she creates an account for example.
Flash[:success] is what I want to show, which is going to be the value of the :success key, thus only.
After tampering with the view, I went to the users_controller.rb file and added the following after I saved a user to database:
def create @user = User.new(params[:user]) if @user.save sign_in @user flash[:success] = "Welcome to Gentle Reminder" redirect_to new_user_goal_path(@user) else render "new" end end
flash[:success] = "Welcome to Gentle Reminder"
is the code that will display the flash message once the user creates an account.