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 , <username>
where username is the name the user logs in.

Regards,

Roelof

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/V5Ca2VfYRw8J.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Norbert Melzer at Nov 12, 2012 at 11:30 am
    :notice => "welcome #{@user.name}"

    That's basic ruby knowledge
    Am 12.11.2012 12:19 schrieb "roelof" <rwobben@hotmail.com>:
    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 , <username>
    where username is the name the user logs in.

    Regards,

    Roelof

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/V5Ca2VfYRw8J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jordon Bedwell at Nov 12, 2012 at 12:48 pm
    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.
    On Mon, Nov 12, 2012 at 5:19 AM, roelof wrote:
    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 , <username>
    where username is the name the user logs in.

    Regards,

    Roelof

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/V5Ca2VfYRw8J.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 12, '12 at 11:19a
activeNov 12, '12 at 12:48p
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase