# Plugin init.rb help

**URL:** <https://www.ruby-forum.com/t/plugin-init-rb-help/124423>\
**Category:** Rails\
**Created:** [December 28, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/plugin-init-rb-help/124423 "2007-12-28T16:31:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 28, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/plugin-init-rb-help/124423/1 "2007-12-28T16:31:59Z")

</div>

Hi,

I have created a plugin that has the following code in the init.rb  
ActionController::Base.send :include, PersonaliseSite

The PersonaliseSite module has a class which\_country that returns ‘uk’  
as a string.

Which means I can sucessfully do somthing like this in my users  
controller

```
#
# render new.rhtml
def new
   @user = User.new
   @user.country = which_country
end

```

However whenever I pass which\_country into the following line of code  
record\_select :per\_page =\> 10,  
:search\_on =\> ‘full\_name’,  
:order\_by =\> “field(country, #{which\_country})”

I get a undefined local variable or method `which\_country’ for  
UsersController:Class error.

Has anyone any suggestions on what is going on and why it can access the  
value within a method but not within the above code

thanks  
scott

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 28, 2007, 4:42pm UTC](https://www.ruby-forum.com/t/plugin-init-rb-help/124423/2 "2007-12-28T16:42:57Z")

</div>

Scott :

> However whenever I pass which\_country into the following line of code  
> record\_select :per\_page =\> 10,  
> :search\_on =\> ‘full\_name’,  
> :order\_by =\> “field(country, #{which\_country})”
> 
> I get a undefined local variable or method `which\_country’ for  
> UsersController:Class error.
> 
> Has anyone any suggestions on what is going on and why it can  
> access the value within a method but not within the above code

Maybe because you should have a instance method called  
which\_country and also a class method called which\_country.

```
-- Jean-François.
```
