# Maybe I can ask here

**URL:** <https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891 "2006-08-15T14:20:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891/1 "2006-08-15T14:20:06Z")

</div>

Sorry, because this is Rails related but it seems not answers are  
forthcoming from the Rails list.

I am working from the Ruby for Rails book , the r4rmusic app.  
All the code is already completed.

However I want to know how or if it’s even possible to access methods  
both within the controllers or models via the script/console ?

Example  
class Composer \< ActiveRecord::Base  
has\_many :works,  
:order =\> “title”

def publishers  
works.editions.publishers.uniq  
end

…

end

How could i access the publishers method via the console ?  
Hope this makes sense.

TIA  
Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891/2 "2006-08-15T14:20:06Z")

</div>

On 8/14/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Sorry, because this is Rails related but it seems not answers are  
> forthcoming from the Rails list.
> 
> I am working from the Ruby for Rails book , the r4rmusic app.  
> All the code is already completed.
> 
> However I want to know how or if it’s even possible to access methods  
> both within the controllers or models via the script/console ?

Should be as simple as starting up the console:

> > composers = Composer.find :all  
> > composers[0].publishers

If not, you may have a configuration problem.

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891/3 "2006-08-15T14:20:06Z")

</div>

Dark A. wrote:

> Sorry, because this is Rails related but it seems not answers are  
> forthcoming from the Rails list.
> 
> I am working from the Ruby for Rails book , the r4rmusic app.  
> All the code is already completed.

Putting aside whether this is the right list for this question (I  
sympathize with your difficulty in getting a response on the Rails  
list), there is a forum set up by Manning for David’s book:

[http://www.manning-sandbox.com/forum.jspa?forumID=200](http://www.manning-sandbox.com/forum.jspa?forumID=200)

–  
James B.

“Take eloquence and wring its neck.”

- Paul Verlaine

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/maybe-i-can-ask-here/64891/4 "2006-08-15T14:20:43Z")

</div>

Dark A. wrote:

> class Composer \< ActiveRecord::Base
> 
> How could i access the publishers method via the console ?  
> Hope this makes sense.
> 
> TIA  
> Stuart

I found you can write ruby programs which include code in the apps  
directory from  
lib/tasks directory if you fool around with the path a little bit

Here is some code I have that runs from the console in the tasks dir  
and includes profile, criteria, match from app/models.

$:.unshift “;…/”  
$:.unshift “;c:/myproj/dateing/app/models/”

require ‘rec\_schema’  
require ‘profile’  
require ‘match’  
require ‘criteria’
