# Adding Subdomain\_fu's 'current\_subdomain' method to models

**URL:** <https://www.ruby-forum.com/t/adding-subdomain-fus-current-subdomain-method-to-models/168207>\
**Category:** Rails\
**Created:** [May 18, 2009, 10:10am UTC](https://www.ruby-forum.com/t/adding-subdomain-fus-current-subdomain-method-to-models/168207 "2009-05-18T10:10:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [May 18, 2009, 10:10am UTC](https://www.ruby-forum.com/t/adding-subdomain-fus-current-subdomain-method-to-models/168207/1 "2009-05-18T10:10:10Z")

</div>

Hi,

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)  
end

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:  
0x3430e60\>

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?
