[Rails] Newb question- method not working

Jan Prill jan.prill at gmail.com
Wed Aug 9 08:01:18 GMT 2006


Hi Dark,

Zacks solution (as well as mine) is assuming that what you get with
session[:user] is indeed an ID that is corresponding to the AR-ID of an
User-Object. If this isn't true it's not working of course.

Regarding your debug output I assume that you wan't to get the id=4 and find
this one on the users table. So you need to find out how to get this id. I
don't know what you are using to write the user to the session but you might
try (and error out) session[:user][:id] or session[:id] or session[:user] or
session[:user].id or session['user'] and so on.

Sometimes you've got to do some trial and error. What's the readme of your
authorization plugin telling?

Cheers,
Jan

On 8/8/06, Dark Ambient <sambient at gmail.com> wrote:
>
> Nope neither of these are working.  Weird.
> With Zack's I keep getting this exception thrown:
> Couldn't find User with ID=59523673
>
> Yet with debug(session) it's showing a differend :user .
>
>
> --- !ruby/object:CGI::Session
> data: &id001
>   :user: 29761836
>   flash: !map:ActionController::Flash::FlashHash {}
>
> bman: &id002 !ruby/object:CGI::Session::ActiveRecordStore
> session: !ruby/object:CGI::Session::ActiveRecordStore::Session
> attributes:
> updated_at: 2006-08-08 14:15:44
> session_id: be9f39bbe191dcf1b1c2f1b111b44c4d
> id: "4"
> data: |
> BAh7BzoJdXNlcmkELCHGASIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6
> Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==
>
>     data: *id001
> dbprot:
> - *id002
> new_session: false
> session_id: be9f39bbe191dcf1b1c2f1b111b44c4d
>
> On 8/8/06, Zack Chandler <zackchandler at gmail.com> wrote:
> > Try
> > <%= User.find(session[:user].id).name %>
> >
> > (assuming user has a name attribute).
> >
> > Hope this helps,
> > Zack
> >
> > On 8/8/06, Dark Ambient <sambient at gmail.com> wrote:
> > > I know this shouldn't be in the view but to test the code it is.
> > > Anyway if I do just session[user] I get back the user id (the id from
> > > the user table)
> > > which is good.
> > > However this code does not work.
> > >
> > > <% a = session[:user] %>
> > > <% uname = User.find(:first, :conditions => id = a) %>
> > > <%= @uname %>
> > >
> > > TIA
> > > Stuart
> > > _______________________________________________
> > > Rails mailing list
> > > Rails at lists.rubyonrails.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails
> > >
> > _______________________________________________
> > Rails mailing list
> > Rails at lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/80ce23d4/attachment.html


More information about the Rails mailing list