Adding methods, accessing from console and rake tasks

another noob question… how do I add methods to a class such that
they can be access from the console and from rake?

Details:

I have a ruby script to fetch tweets from the search api. That works
fine, saves my tweets to the db. I have a separate, basic rails app to
view and manage the tweets and search queries. All of that works fine,
too.

Now I want to integrate the script into the rails app so it:
-runs as a rake task
-runs from cron
-runs from a refresh button on the tweets page

The original ruby script has two methods: search_twitter and
get_tweets. I copied those into the Tweet controller, but I cannot
access them from the rake file or from the console. If I do
Tweet.methods from the console, neither method shows up.

So - where is the correct place for these methods, and how do I access
them from rake and the console?

Thanks!

-Luke

On Apr 10, 4:35 am, LukeG [email protected] wrote:

The original ruby script has two methods: search_twitter and
get_tweets. I copied those into the Tweet controller, but I cannot
access them from the rake file or from the console. If I do
Tweet.methods from the console, neither method shows up.

So - where is the correct place for these methods, and how do I access
them from rake and the console?

I’d create a model that did these tweet related tasks (or add them to
an existing one if appropriate)

Fred

Putting them in the model helped, getting a quick schooling in OOP
from someone else helped, too :slight_smile:

I changed the methods to class methods, and now it behaves as
expected.

Thanks!

On Apr 10, 2:55 am, Frederick C. [email protected]