I''d like to create an web app that would let users perform fairly simple conversions (say, converting a sports competition time done in meters to the corresponding time done in yards). All ajaxy and stuff. I probably wouldn''t need a database for this application. I''m thinking I''d just need a model that contained the necessary smarts for doing the conversions and then hook up the controller to that. How do I go about doing that?
Just create a basic class in your models dir, and access it normally. Don''t need to do anything special. Pat On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''d like to create an web app that would let users perform fairly > simple conversions (say, converting a sports competition time done in > meters to the corresponding time done in yards). All ajaxy and stuff. > > I probably wouldn''t need a database for this application. I''m > thinking I''d just need a model that contained the necessary smarts for > doing the conversions and then hook up the controller to that. > > How do I go about doing that? > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 8/6/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Just create a basic class in your models dir, and access it normally. > Don''t need to do anything special.Doh, that easy? Doesn''t need to inherit from anything?> > On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''d like to create an web app that would let users perform fairly > > simple conversions (say, converting a sports competition time done in > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > I probably wouldn''t need a database for this application. I''m > > thinking I''d just need a model that contained the necessary smarts for > > doing the conversions and then hook up the controller to that. > > > > How do I go about doing that? > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/6/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Just create a basic class in your models dir, and access it normally. > > Don''t need to do anything special. > > Doh, that easy? Doesn''t need to inherit from anything?And if I wanted to do unit tests on it? Just create the test file in test/unit and require it?> > > > > On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''d like to create an web app that would let users perform fairly > > > simple conversions (say, converting a sports competition time done in > > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > > > I probably wouldn''t need a database for this application. I''m > > > thinking I''d just need a model that contained the necessary smarts for > > > doing the conversions and then hook up the controller to that. > > > > > > How do I go about doing that? > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Do you have the Agile book? If so, take a look at the Cart model...it''s a pure Ruby class. The models dir doesn''t really enforce anything, you can put whatever Ruby code you want in there. A lot of a Rails app''s structure is just to provide logical organization for your classes. A class that inherits from AR::Base is just a regular Ruby class...except it gains some extra functionality from the parent. So you''re free to use pure Ruby models in there, just remember to specify accessors for the attributes, and explicitly initialize them in initialize(), etc. Pat On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/6/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Just create a basic class in your models dir, and access it normally. > > Don''t need to do anything special. > > Doh, that easy? Doesn''t need to inherit from anything? > > > > > On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''d like to create an web app that would let users perform fairly > > > simple conversions (say, converting a sports competition time done in > > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > > > I probably wouldn''t need a database for this application. I''m > > > thinking I''d just need a model that contained the necessary smarts for > > > doing the conversions and then hook up the controller to that. > > > > > > How do I go about doing that? > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I would just copy an existing unit test file over, because it doesn''t have any AR-specific stuff in it. All you need to do is require the test_helper stuff and extend your class from TestCase: require File.dirname(__FILE__) + ''/../test_helper'' class Cart_Test < Test::Unit::TestCase ... end You can load in fixtures if your model relies on some data from the db, define setup and teardown methods, etc. Pat On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 8/6/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Just create a basic class in your models dir, and access it normally. > > > Don''t need to do anything special. > > > > Doh, that easy? Doesn''t need to inherit from anything? > > And if I wanted to do unit tests on it? Just create the test file in > test/unit and require it? > > > > > > > > > On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''d like to create an web app that would let users perform fairly > > > > simple conversions (say, converting a sports competition time done in > > > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > > > > > I probably wouldn''t need a database for this application. I''m > > > > thinking I''d just need a model that contained the necessary smarts for > > > > doing the conversions and then hook up the controller to that. > > > > > > > > How do I go about doing that? > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''d like to create an web app that would let users perform fairly > simple conversions (say, converting a sports competition time done in > meters to the corresponding time done in yards). All ajaxy and stuff. > > I probably wouldn''t need a database for this application. I''m > thinking I''d just need a model that contained the necessary smarts for > doing the conversions and then hook up the controller to that. > > How do I go about doing that?Ajax question now: <%= form_remote_tag(:update => "update_div", :url => { :action => :yards_to_meters })%> I have a method in the controller called yards_to_meters. When I click the submit button, the page is refreshed and I''m taken to /the_controller/yards_to_meters. But I want to stay on the same page and have the result of yards_to_meters placed in the update_div div. Any ideas?
On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''d like to create an web app that would let users perform fairly > > simple conversions (say, converting a sports competition time done in > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > I probably wouldn''t need a database for this application. I''m > > thinking I''d just need a model that contained the necessary smarts for > > doing the conversions and then hook up the controller to that. > > > > How do I go about doing that? > > Ajax question now: > > <%= form_remote_tag(:update => "update_div", > :url => { :action => :yards_to_meters })%> > > I have a method in the controller called yards_to_meters. When I > click the submit button, the page is refreshed and I''m taken to > /the_controller/yards_to_meters. But I want to stay on the same page > and have the result of yards_to_meters placed in the update_div div. > > Any ideas?I''ve got one. How about including <%= javascript_include_tag "prototype" %> inside your <head> section? Dumbass. :(
Woah, woah! No need to get hostile! You need to love yourself before you can spread it to others! :) - Aaron ''Jomdom'' Ransley - Web: www.jomdom.net - Mail: jomdom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Joe Van Dyk Sent: Saturday, August 06, 2005 1:31 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] Re: model without database table On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''d like to create an web app that would let users perform fairly > > simple conversions (say, converting a sports competition time done in > > meters to the corresponding time done in yards). All ajaxy and stuff. > > > > I probably wouldn''t need a database for this application. I''m > > thinking I''d just need a model that contained the necessary smarts for > > doing the conversions and then hook up the controller to that. > > > > How do I go about doing that? > > Ajax question now: > > <%= form_remote_tag(:update => "update_div", > :url => { :action => :yards_to_meters })%> > > I have a method in the controller called yards_to_meters. When I > click the submit button, the page is refreshed and I''m taken to > /the_controller/yards_to_meters. But I want to stay on the same page > and have the result of yards_to_meters placed in the update_div div. > > Any ideas?I''ve got one. How about including <%= javascript_include_tag "prototype" %> inside your <head> section? Dumbass. :( _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails