How can I change the notice to a text with a variable

Hello,

I have this controller :

class UserSessionsController < ApplicationController skip_before_filter :require_login, :except => [:destroy] def new @user = User.new end

def create respond_to do |format| if @user = login(params[:username],params[:password]) format.html { redirect_back_or_to(:users, :notice => ‘login successfull’) } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { flash.now[:alert] = “Login failed.”; render :action => “new” } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end

def destroy logout redirect_to(:users, :notice => ‘Logged out!’) end end

What’s the best way to change “login successfull” to "Welcome , where username is the name the user logs in.

Regards,

Roelof

:notice => “welcome #{@user.name}”

That’s basic ruby knowledge

redirect_back_or_to(:users, notice: "Welcome, #{@user.username}")

Though you shouldn't do that in the redirect, you should probably just make that a default part of the view if the session has a user_id.