Stuart Hungerford
2005-Mar-17 01:00 UTC
Rails project with no relational database component?
Hi all, This is possibly a silly question, but anyway: Can Ruby On Rails be used to host a website that has no relational database component? Or is the database component such an important part of the Rails experience that it doesn''t make sense? I have a project in mind where the "database" is a bunch of XML files and file system directories. Any pointers to non-database Rails projects much appreciated. Stu
Michael Koziarski
2005-Mar-17 01:20 UTC
Re: Rails project with no relational database component?
On Thu, 17 Mar 2005 01:00:14 +0000 (UTC), Stuart Hungerford <stuart.hungerford-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org> wrote:> Hi all, > > This is possibly a silly question, but anyway: > > Can Ruby On Rails be used to host a website that has no > relational database component? Or is the database > component such an important part of the Rails > experience that it doesn''t make sense?No way, unfortunately I can''t send you the code but I''m currently running a rails application with no database. It''s just a wrapper around another library and some shell scripts. I just wrote standard ruby classes and dumped them in /vendor. Then all the controllers and Views can just manipulate them like anything else. The only thing you''ll have to do is implement your own validation & attributes= methods if you need them.> I have a project in mind where the "database" is a bunch > of XML files and file system directories. > > Any pointers to non-database Rails projects much > appreciated. > > Stu > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Steven Critchfield
2005-Mar-17 01:30 UTC
Re: Rails project with no relational database component?
On Thu, 2005-03-17 at 01:00 +0000, Stuart Hungerford wrote:> Hi all, > > This is possibly a silly question, but anyway: > > Can Ruby On Rails be used to host a website that has no > relational database component? Or is the database > component such an important part of the Rails > experience that it doesn''t make sense? > > I have a project in mind where the "database" is a bunch > of XML files and file system directories. > > Any pointers to non-database Rails projects much > appreciated.Rails isn''t tied to databases. It does however seem tied to having models. Models however can be implemented anyway you want. I''m sure you could write a model that splits out the XML and presents the fragments as objects. Same for the system directories. -- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
Michael Koziarski
2005-Mar-17 01:48 UTC
Re: Rails project with no relational database component?
On Wed, 16 Mar 2005 19:30:43 -0600, Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org> wrote:> On Thu, 2005-03-17 at 01:00 +0000, Stuart Hungerford wrote: > > Hi all, > > > > This is possibly a silly question, but anyway: > > > > Can Ruby On Rails be used to host a website that has no > > relational database component? Or is the database > > component such an important part of the Rails > > experience that it doesn''t make sense? > > > > I have a project in mind where the "database" is a bunch > > of XML files and file system directories. > > > > Any pointers to non-database Rails projects much > > appreciated. > > Rails isn''t tied to databases. It does however seem tied to having > models. Models however can be implemented anyway you want. I''m sure you > could write a model that splits out the XML and presents the fragments > as objects. Same for the system directories.Remember, Models are just the classes that correspond to the business logic for your application. So every framework out there is tied to having models, whether they use that word or not ;)> -- > Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Tobias Luetke
2005-Mar-17 02:41 UTC
Re: Rails project with no relational database component?
> Now, this will create three Image objects, right? So, if each image > is 500KB, that''s at least a 1.5MB database transfer (right?). I > really only need each image id.No problem at all. There are plenty projects out there which don''t use a database. Instiki and Damage control both are such projects and open source as well. All you need to do is to take out the require_gem active_record and the establish connection call in the environment.rb After that you can even delete the config/database.yml -- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
Stuart Hungerford
2005-Mar-17 02:43 UTC
Re: Rails project with no relational database component?
Michael Koziarski wrote:> On Thu, 17 Mar 2005 01:00:14 +0000 (UTC), Stuart Hungerford > <stuart.hungerford-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org> wrote: > >>Hi all, >> >>This is possibly a silly question, but anyway: >> >>Can Ruby On Rails be used to host a website that has no >>relational database component? Or is the database >>component such an important part of the Rails >>experience that it doesn''t make sense? > > > No way, unfortunately I can''t send you the code but I''m currently > running a rails application with no database. It''s just a wrapper > around another library and some shell scripts. > > I just wrote standard ruby classes and dumped them in /vendor. Then > all the controllers and Views can just manipulate them like anything > else. The only thing you''ll have to do is implement your own > validation & attributes= methods if you need them.Thanks for that prompt reply. Can I ask why /vendor is the appropriate directory for this -- or will the reason for it become obvious as I learn more about Rails? Stu
Tobias Luetke
2005-Mar-17 02:43 UTC
Re: Rails project with no relational database component?
Sorry, wrong thing in the clipboard. I meant to quote :> Can Ruby On Rails be used to host a website that has no > relational database component? Or is the database > component such an important part of the Rails > experience that it doesn''t make sense?Answer again: No problem at all. There are plenty projects out there which don''t use a database. Instiki and Damage control both are such projects and open source as well. All you need to do is to take out the require_gem active_record and the establish connection call in the environment.rb After that you can even delete the config/database.yml -- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
Michael Koziarski
2005-Mar-17 02:45 UTC
Re: Re: Rails project with no relational database component?
On Thu, 17 Mar 2005 13:43:15 +1100, Stuart Hungerford <stuart.hungerford-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org> wrote:> Michael Koziarski wrote: > > > On Thu, 17 Mar 2005 01:00:14 +0000 (UTC), Stuart Hungerford > > <stuart.hungerford-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org> wrote: > > > >>Hi all, > >> > >>This is possibly a silly question, but anyway: > >> > >>Can Ruby On Rails be used to host a website that has no > >>relational database component? Or is the database > >>component such an important part of the Rails > >>experience that it doesn''t make sense? > > > > > > No way, unfortunately I can''t send you the code but I''m currently > > running a rails application with no database. It''s just a wrapper > > around another library and some shell scripts. > > > > I just wrote standard ruby classes and dumped them in /vendor. Then > > all the controllers and Views can just manipulate them like anything > > else. The only thing you''ll have to do is implement your own > > validation & attributes= methods if you need them. > > Thanks for that prompt reply. Can I ask why /vendor is the > appropriate directory for this -- or will the reason for it > become obvious as I learn more about Rails?I put it in vendor as I use that library elsewhere, I don''t believe that there''s any real reason not to. /app/model would also have been fine.> > Stu > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Justin Forder
2005-Mar-17 02:50 UTC
Re: Rails project with no relational database component?
Tobias Luetke wrote:>>Can Ruby On Rails be used to host a website that has no >>relational database component? Or is the database >>component such an important part of the Rails >>experience that it doesn''t make sense? > > No problem at all. There are plenty projects out there which don''t use > a database. > > Instiki and Damage control both are such projects and open source as well. > > All you need to do is to take out the require_gem active_record and > the establish connection call in the environment.rb > > After that you can even delete the config/database.ymlMost (all?) tutorials show how to wire up forms to ActiveRecords, and rely on features of the ActiveRecord interface. Is there guidance available on working with Plain Old Ruby Objects? Or perhaps a mixin to give the relevant ActiveRecord interface and behaviour? Justin
Jim Weirich
2005-Mar-17 04:15 UTC
Re: Rails project with no relational database component?
On Wednesday 16 March 2005 08:00 pm, Stuart Hungerford wrote:> This is possibly a silly question, but anyway: > > Can Ruby On Rails be used to host a website that has no > relational database component? Or is the database > component such an important part of the Rails > experience that it doesn''t make sense?I''m playing with a rails app that is just a view on some public directories. The model objects are loaded from files in those directories. I wrote a noop connection adapter that just does nothing when connecting to the database. -- -- Jim Weirich jim-Fxty1mrVU9GlFc2d6oM/ew@public.gmane.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
Stuart Hungerford
2005-Mar-18 00:07 UTC
Re: Rails project with no relational database component?
Jim Weirich wrote:> On Wednesday 16 March 2005 08:00 pm, Stuart Hungerford wrote: > >>This is possibly a silly question, but anyway: >> >>Can Ruby On Rails be used to host a website that has no >>relational database component? Or is the database >>component such an important part of the Rails >>experience that it doesn''t make sense? > > > I''m playing with a rails app that is just a view on some public directories. > The model objects are loaded from files in those directories. I wrote a noop > connection adapter that just does nothing when connecting to the database.Will you be making this app available? I don''t need anything productized, just some way to view the source. Stu
John W. Long
2005-Mar-19 05:04 UTC
Re: Rails project with no relational database component?
Jim Weirich wrote:> I''m playing with a rails app that is just a view on some public directories. > The model objects are loaded from files in those directories. I wrote a noop > connection adapter that just does nothing when connecting to the database.A noop adapter? Why not just include ActiveRecord::Validations into your model? Define a small class like this: class BaseRecord def save; end def update_attribute; end def new_record?; end include ActiveRecord::Validations def [](key) instance_variable_get(key) end end This allows you to do regular validations on your model: class Address < BaseRecord attr_accessor :line_one, :line_two, :city, :province, :postal_code, :phone validates_presence_of :line_one, :city, :province, :postal_code, :message => "required" end a = Address.new a.valid? #=> false I''d love to see the validation''s part abstracted a little more away from ActiveRecord. (Move it into a module called Validateable.) It seems a little silly that inorder to use this great module we have to define three methods that don''t have anything to do with validation. -- John Long http://wiseheartdesign.com