Maybe I can ask here

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

On 8/14/06, Dark A. [email protected] 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.

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


James B.

“Take eloquence and wring its neck.”

  • Paul Verlaine

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’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs