surf
8/15/2006 1:45:00 AM
Dark Ambient 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 ?
>
> 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
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'