Forum: Ruby on Rails Adding Subdomain_fu's 'current_subdomain' method to models

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ram (Guest)
on 2009-05-18 12:10
(Received via mailing list)

I have a view in which i have the following collection_select

<%= f.collection_select :category_id, current_account.categories.find
(:all), :id, :name, {:prompt => "-Select-", :include_blank => true} %>

and the current_account method in authentication.rb is

def current_account
    @current_account ||= Account.find_by_subdomain(current_subdomain)

But i get the following error when i try to open the page with that
collection_select in it

undefined local variable or method `current_subdomain' for #<Project:

Does this mean i have to make this method available to all my models?
i also tried moving "current_account.categories.find(:all)" to the
controller and storing it in an instance variable and using the
instance variable here instead like

@categories = current_account.categories.find(:all)

<%= f.collection_select :category_id, @categories, :id, :name,
{:prompt => "-Select-", :include_blank => true} %>

That too threw the same error. Any idea whats the ideal way to handle
This topic is locked and can not be replied to.