Andrew Filipowski
2006-Jan-10 13:07 UTC
[Rails] 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: File.join("test",User.find(self.user_id).companyname,"image") I have also tried: File.join("test",User.find(self.user.id).companyname,"image") 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 Object.new (params[:object]) that the object at least resides in memory at this point (I am doing the object.new 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) Andrew
Maybe Matching Threads
- Getting a user from a model (sort of a noob) (resend sorry)
- File_column Dynamic directory
- Called id for nil, which would mistakenly be 4 -- if you really wanted the idof nil, use object_id - solved
- PJSIP configuration question
- Samba4 AD DNS -- AD Subdomain vs Clients accessing on different subdomain