Exception: can't dup Symbol

Hey everybody,

I’m trying to test a little piece of code I wrote, and I get the
following error:

Exception: can’t dup Symbol

It happens in the following line: try_to_login @valid_user, :remember_me
=> “1”,
where the function try_to_login is:

def try_to_login(user, options = {})
user_hash = {:screen_name => user.screen_name, :password =>
user.password}
user_hash.merge!(options)
post :login, :user => :user_hash
assert logged_in?
end

I can’t isolate the error, can anybody throw some light on it?

Thanks a lot in advance!

Hi,

It looks like maybe issue with passing the remember_me as part of
params[:user] … can you post your controller’s action handling this
request ?

regards,
Sur
http://rubyonrailshacks.com

Manu L. wrote:

Hey everybody,

I’m trying to test a little piece of code I wrote, and I get the
following error:

Exception: can’t dup Symbol

It happens in the following line: try_to_login @valid_user, :remember_me
=> “1”,
where the function try_to_login is:

def try_to_login(user, options = {})
user_hash = {:screen_name => user.screen_name, :password =>
user.password}
user_hash.merge!(options)
post :login, :user => :user_hash
assert logged_in?
end

I can’t isolate the error, can anybody throw some light on it?

Thanks a lot in advance!

Sur M. wrote:

Hi,

It looks like maybe issue with passing the remember_me as part of
params[:user] … can you post your controller’s action handling this
request ?

regards,
Sur
http://rubyonrailshacks.com

Manu L. wrote:

Hey everybody,

I’m trying to test a little piece of code I wrote, and I get the
following error:

Exception: can’t dup Symbol

It happens in the following line: try_to_login @valid_user, :remember_me
=> “1”,
where the function try_to_login is:

def try_to_login(user, options = {})
user_hash = {:screen_name => user.screen_name, :password =>
user.password}
user_hash.merge!(options)
post :login, :user => :user_hash
assert logged_in?
end

I can’t isolate the error, can anybody throw some light on it?

Thanks a lot in advance!

def login
@title = “Log in to RailsSpace”
if request.get?
@user = User.new(:remember_me => cookies[:remember_me] || “0”)
elsif param_posted?(:user)
@user = User.new(params[:user])
user =
User.find_by_screen_name_and_password(@user.screen_name,@user.password)
if user
user.login!(session)
if @user.remember_me == “1”
cookies[:remember_me] = { :value => “1”, :expires =>
10.years_from_now }
user.authorization_token =
Digest::SHA1.hexdigest(“#{user.screen_name}:#{user.password}”)
user.save!
cookies[:autorization_token] = { :value =>
user.authorization_token, :expires => 10.years_from_now }
else
cookies.delete(:remember_me)
cookies.delete(:authorization_token)
end
flash[:notice] = “User #{user.screen_name} logged in!”
redirect_to_forwarding_url
else
@user.clear_password!
flash[:notice] = “Invalid screen name/password combination”
end
end
end

On Jul 31, 5:03 pm, Manu L. [email protected] wrote:

def try_to_login(user, options = {})
user_hash = {:screen_name => user.screen_name, :password =>
user.password}
user_hash.merge!(options)
post :login, :user => :user_hash

You meant to write :user => user_hash

Fred

Frederick C. wrote:

On Jul 31, 5:03�pm, Manu L. [email protected] wrote:

def try_to_login(user, options = {})
� � user_hash = {:screen_name => user.screen_name, :password =>
user.password}
� � user_hash.merge!(options)
� � post :login, :user => :user_hash

You meant to write :user => user_hash

Fred

Great! You got it! Thanks a lot!