>> So you mean doing something like this in the application controller?
>>   def current_user
>>     User.find_by_id(session[:user_id])
>>   end
> That's usually sensible.
>
> Since current_user is defined in
> ApplicationController, and since all your other controllers inherit from
> ApplicationController, all you need in your controller is
>
> @current_user = current_user
>
> and then do @current_user.account.whatever in the view.
>
>> How can I make the company name available to all views with something
>> like this... @company_name

I tried it, and it does work. But how can I make it work on the 
APPLICATION CONTROLLER instead of on an individual controller. Several 
views need the account_id, so I would have to repeat myself in several 
controllers writing
@company_name = company_name

For example with this code in the application controller...

  def company_id
    @company_id = User.find_by_id(session[:user_id]).account.id
  end
  @company_id = company_id

I get this error...
Routing Error
undefined local variable or method `company_id' for 
ApplicationController:Class

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to