Getting a user from a model (sort of a noob)

As mentioned in my previous posts I’m trying to create a dynamic
directory for file_folumn. After finding out that I didn’t have the
most recent version I installed the latest trunk and am able to get
file_column to act as it should. However I have been racking my brain
on how to implement finding my current user from a model. I have
tried everything in my basic/getting better knowledge of Rails and
Ruby but have been striking out so far no luck. I am assuming others
have done this so just some tips on how to get at this info would be
greatly appreciated. The model that I am trying to get at the user
info from does have a belongs_to relationship to my user. Here is my
last attempt which comes back with a user can’t be found without an
ID=0 error:


I have also tried:


And receive the Called id for nil, which would mistakenly be 4 – if
you really wanted the id of nil, use object_id error message. By my
knowledge this makes sense as the object that I am creating has not
totally been saved yet but I thought that by calling an
(params[:object]) that the object at least resides in memory at this
point (I am doing the at the beginning of my create method
in the controller for that model). Am I on the right path here or
just running around in circles?

Thanks for all the help from everyone on the list without it I would
be having a much harder time than I am getting my head wrapped around
Ruby and Rails (I am working under a deadline and have been forced to
learn at the same time that I am writing a product for release for
our company)


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs