On 13 October 2010 21:42, Leonel *.* <[email protected]> wrote:
> Simplified it even moreeeee for the designer...
>
> CONTROLLER
> @company_name = User.find(session[:user_id]).account.name

OK, but did you take heed of my warning in my first reply?  Can you
guarantee that a user will always have a company (even in unusual
circumstances)?  Add into your automated tests one where the user does
not have a company and see what happens.  (Hint, find returns nil if
it cannot find what you are asking for).

Another point, it might be worth providing a method somewhere called
current_user (possibly in application_controller) that does the find,
then you will not need to keep typing the find everywhere you want
current_user.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to