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! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 Lorenzo 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!-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sur Max 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 Lorenzo 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 -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 31, 5:03 pm, Manu Lorenzo <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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_hashYou meant to write :user => user_hash Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> On Jul 31, 5:03�pm, Manu Lorenzo <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 > > FredGreat! You got it! Thanks a lot! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.