Forum: Ruby on Rails undefined method `include?'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Patrick L. (Guest)
on 2008-12-03 11:02
Hi guys,
I was just working on this application (http://pastie.org/329613) when I
added this line "session[:user].include?(params[:id])" to an unless
statement and the app threw this error:

NoMethodError in SignupsController#show
undefined method `include?' for 27:Fixnum
Application Trace: app/controllers/signups_controller.rb:35:in
`authorize'

Any ideas? Thanks in advance!
Franz S. (Guest)
on 2008-12-03 11:14
(Received via mailing list)
On Wed, Dec 3, 2008 at 10:02 AM, Patrick L.
<removed_email_address@domain.invalid> wrote:
>
> Hi guys,
> I was just working on this application (http://pastie.org/329613) when I
> added this line "session[:user].include?(params[:id])" to an unless
> statement and the app threw this error:

session is a Hash, and when you do session[:user], you're getting back
the
value referenced by the key :user.

> NoMethodError in SignupsController#show
> undefined method `include?' for 27:Fixnum

and it turns out that you stored 27 in there.

You may simply check the value against the params, if that's what you
need
to do à la if session[:user] == params[:id]

Franz
This topic is locked and can not be replied to.