I have justs started a file upload applciation. I am using the
Login_Sugar project as well. It has a User model. My file upload has a
Content model. The contents table has a foreign_key constrains on the
users table (in other words, each piece of content is owned by one
user).
The upload controller passes control to the Content model which needs to
define the “user” member. This is kept in the session and can be
accessed by the controller via “session[:user]”.
How do I pas the session or the user object to the model?
Note: I’m sure there must be a standard and easy way to do this. A way
that does not involve passing another parameter to the Content’s
constructor.
I tried writing a class method in the controller to simply return the
session[:user] but when called from the context of the Content model it
always returns nil (the session is nil at this point).
Any ideas ont is would beappreciated. I’m new to Ruby+Rails.