From: Ezra Zygmuntowicz Date: 2005-11-12T06:28:08+09:00 Subject: Re: Ruby / Rails discrepancies On Nov 11, 2005, at 10:27 AM, burak@lysurge.net wrote: > My code now looks like this, yet still the same error. If I try taking > out the "< ApplicationController" i get an even scarier error > (undefined method `controller_path' for EnginesController:Class) so I > just left it in. > > Any ideas? Like I said before, you need to make this class a model class not a controller. And don't have it inherit from anything. Lets say you call this class YahooSearch: Create a file called yahoo_search.rb and put it in your model directory > require 'net/http' > require 'mechanize' > > class YahooSearch > > def yahoo > > agent = WWW::Mechanize.new > agent.user_agent_alias = 'Windows IE 6' > page = > agent.get('https://login.yahoo.com/config/login? > login=xxxxx&passwd=xxxxx&tries=1&.src=srch&.lg=us&partner=&submit=Sign > +In&.done=http://submit.search.yahoo.com/free/request') > page = > agent.get('http://submit.search.yahoo.com/free/request? > class=Submit&pass=1&url=http%3A//www.lysurge.net') > @data=page > end > end Now in any controller in your application you can use it like this: class EnginesController < ApplicationController model :yahoo_search def search @data = YahooSearch.yahoo end end And now you can call your search with the url http://example.com/ engine/search Make sense? Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com