Hi, I'm trying create a user system for a future project but I have a
problem when I want give to my users the "Welcome". This is my code:
#application_controller
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
@current_user = current_user_session && current_user_session.user
end
end
#welcome_controller
class WelcomeController < ApplicationController
def hi
@current_user
if (@current_user)
@welr = '¡Bienvenido' + @current_user + ' a nuestra web!'
else
@weli = "¡Bienvenido invitado, no dude en registrarse!"
end
end
end
#user_sessions_controller
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Estás dentro de nuestro sistema"
redirect_to root_url
else
render :action => 'new'
end
end
def destroy
@user_session = UserSession.find
@user_session.destroy
flash[:notice] = "Usted está fuera de nuestro sistema"
redirect_to root_url
end
end
#hi.html.erb
<h1><%= @controller.hi %></h1>
I believe that my problem are in the variable that I'm use, but I have
tried with @user_session and nothing.
Anyone know?
Regards, Iván
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.