# Re: Engine installer

**URL:** <https://www.ruby-forum.com/t/re-engine-installer/56999>\
**Category:** Engines Development\
**Created:** [April 6, 2006, 12:58pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999 "2006-04-06T12:58:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_AE\_Scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6bbea6/32.png) [@Vincent\_AE\_Scott](https://www.ruby-forum.com/u/Vincent_AE_Scott)\
**Post date:** [April 6, 2006, 12:58pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999/1 "2006-04-06T12:58:14Z")

</div>

Hi there,  
I’m running into a spot of bother with an engine I’m developing. I want  
the table names I’m using to be configurable by the end user, such that  
nothing is hard coded. Having looked through user\_engine, I see it  
makes use of things like: UserEngine.config(:some\_table). I’m trying  
todo the same thing, like in the following:

has\_many :mac\_user\_grants, :class\_name =\>  
MacEngine.config(:mac\_user\_grant\_table)

But when i come to use the class this is in I get an error like the  
following:

NameError: undefined local variable or method `mac\_user\_grants’ for  
MacAcl:Class

in my mac\_engine.rb file, I have the following:

module MacEngine  
if ActiveRecord::Base.pluralize\_table\_names  
config :mac\_user\_grant\_table, “mac\_user\_grants”  
else  
config :mac\_user\_grant\_table, “mac\_user\_grant”  
end  
end

I’m guessing the problem lies with how/what  
MacEngine.config(:mac\_user\_grant\_table) returns, and how it gets  
interpreted.

I’ve tried the following to no avail:

:class\_name =\> “#{MacEngine.config(:mac\_user\_grant\_table)}”  
:class\_name =\> MacEngine.config(:mac\_user\_grant\_table).to\_s

So my question is, and its probably more of a general Ruby question than  
an engines one, what is :class\_name expecting, and how can i provide it?

-v

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

Mankind must put an end to war, or war will put an end to mankind  
– JFK

---

<div class="post-metadata">

**Author:** ![Vincent\_AE\_Scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6bbea6/32.png) [@Vincent\_AE\_Scott](https://www.ruby-forum.com/u/Vincent_AE_Scott)\
**Post date:** [April 6, 2006, 1:01pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999/2 "2006-04-06T13:01:17Z")

</div>

oops, appologies for replying to a previous post and forgetting to  
change the subject line after having removed the InReplyTo:

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

Heisenberg may have slept here

---

<div class="post-metadata">

**Author:** ![Vincent\_AE\_Scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6bbea6/32.png) [@Vincent\_AE\_Scott](https://www.ruby-forum.com/u/Vincent_AE_Scott)\
**Post date:** [April 6, 2006, 1:07pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999/3 "2006-04-06T13:07:39Z")

</div>

Well, I’ll respond here then.

[http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000527](http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000527)

If you look at some of the examples that use the :class\_name  
parameter, it does want strings, but of the actual _class_ name, not  
the table name. Luckily Rails rocks and provides a method on string to  
convert a table name to a class name:

:class\_name =\> MacEngine.config(:mac\_user\_grant\_table).classify

I think that should do it.

-jeff

On 4/6/06, Vincent AE Scott [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> engine-developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–  
Jeff L.  
[http://blogrium.com/](http://blogrium.com/)

---

<div class="post-metadata">

**Author:** ![Vincent\_AE\_Scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6bbea6/32.png) [@Vincent\_AE\_Scott](https://www.ruby-forum.com/u/Vincent_AE_Scott)\
**Post date:** [April 6, 2006, 1:13pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999/4 "2006-04-06T13:13:46Z")

</div>

#if progrium /\* Apr 06, 04:04 \*/

> I think that should do it.

Ahha! perfect, appologies for not RTFM’in

Just before you responded i tried:  
“MacEngine::” + MacEngine.config(:mac\_user\_grant\_table).to\_s.camelize

and that also failed to work, I guess for exactly the same reason.

> -jeff

#endif /\* removed\_email\_address@domain.invalid \*/

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

When the rich wage war, it’s the poor who die.  
– Jean-Paul Sartre

---

<div class="post-metadata">

**Author:** ![Vincent\_AE\_Scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6bbea6/32.png) [@Vincent\_AE\_Scott](https://www.ruby-forum.com/u/Vincent_AE_Scott)\
**Post date:** [April 6, 2006, 1:22pm UTC](https://www.ruby-forum.com/t/re-engine-installer/56999/5 "2006-04-06T13:22:59Z")

</div>

It’s a Rails question, rather than a Ruby one, but here goes.

The :class\_name argument is expecting something of the form  
“MacUserGrants”, and that might not be the same as your table name  
(which is probably “mac\_user\_grants”, as you set it in the config).  
It’s expecting a string representation of an actual Ruby class (and a  
subclass of ActiveRecord::Base in this particular case).

I think you’re more likely to want to do something like this:

class Something \< ActiveRecord::Base  
has\_many :mac\_user\_grants  
end

class MacUserGrants \< ActiveRecord::Base  
set\_table\_name MacEngine.config(:mac\_user\_grants\_table)  
end

… the table name is only really relevant in the class which stores  
data in that table in this case.

- james

On 4/6/06, Vincent AE Scott [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> following:  
> end
> 
> – JFK
> 
> * * *
> 
> engine-developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–

- J \*  
~
