I have also understood it like this; anyway such a feature is very important (maybe the ability to choose between a calendar and links for each month). It would be very nice to have the db-independence in RoR directly, but because the queries are SQL-based it is more difficult to acheive this. Something like HQL would be nice. I think I will take a better look at RoR and write about this issue on a specific mailing list. Anyway - Typo guys are RoR guys so I hope I'm not very off topic.
Stuart Smith wrote: > Isn't the issue being discussed here the method by which a list of links > reflecting the month/year of the article is generated? I see now that > typo supports the year/month/day (optional) argument list but how do we > get from article creation dates to a list of months&years using non- > specific date formatting that works for all DB's. > > Stuart > > On Tue, 2005-04-12 at 17:04 -0400, Tobias Luetke wrote: > >>Typo supports this already. >> >>http://blog.leetsoft.com/articles/2005/ >>http://blog.leetsoft.com/articles/2005/03/ >>http://blog.leetsoft.com/articles/2005/03/28/ >> >>On Apr 12, 2005 4:21 PM, Stuart Smith >><[EMAIL PROTECTED]> wrote: >> >>>I misunderstood the database dependency issues; I just assumed that >>>since an ISP/host would run typo against a specific persistent storage >>>mechanism then a specific version of archive.rb would be installed on >>>the target system. I just saw this as an extension of the multiple SQL >>>files to create the initial schema for a specific vendor db. >>> >>>It would be interesting to see what others make of the problem regarding >>>vendor specific SQL statements. There are companies that make a living >>>from 'middleware' to allow the coder to write non-specific SQL (e.g. >>>RogueWave had something called dbtools.h that I used a long time ago but >>>that was a real 'pain in the ass' to use). >>> >>>Thanks >>> >>>Stuart >>> >>> >>> >>>>>app/models/archive.rb >>>>> >>>>>class Archive < ActiveRecord::Base >>>>> >>>>> has_many :articles >>>>> >>>>> def self.find_dates() >>>>> @archives=Article.find_by_sql(["SELECT distinct date_format >>>>>(created_at, '%%M %%Y') date from articles ORDER by created_at "]) >>>>> end >>>>> >>>>>end >>>>> >>> >>>_______________________________________________ >>>Typo-list mailing list >>>[email protected] >>>http://rubyforge.org/mailman/listinfo/typo-list >>> >> >> > > _______________________________________________ > Typo-list mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/typo-list > > From stuart.smith at smsconsulting.wanadoo.co.uk Wed Apr 13 15:10:18 2005 From: stuart.smith at smsconsulting.wanadoo.co.uk (Stuart Smith) Date: Wed Apr 13 15:03:57 2005 Subject: [typo] ticket #13 - add Archive articles by month (I hope this is what it means!) In-Reply-To: <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Hi Tobias, I took on board your comment and have reduced the solution to this: ########################################################################### app/views/shared/_archives.rhtml [new file] <b>Archives</b><br/> <% for archive in archives -%> <%= link_to archive.dispdate, "/articles/"+archive.date %><br/> <% end -%> app/views/layouts/articles.rhtml [add code nr categorylist] <%= archivelist %> <br/> app/models/article.rb [ new function ] def self.find_dates() @archives=Article.find_by_sql(["SELECT distinct date_format (created_at, '%%M %%Y') dispdate, date_format(created_at, '%%Y/%%m') date from articles ORDER by created_at "]) end app/helpers/application_helper.rb [ new function ] def archivelist() archives = Article.find_dates() render_partial("shared/archives", archives) end ############################################################################ This is now a lot simpler than before but still contains some MySql specific date formatting. I would appreciate any comments from anyone. regards Stuart Smith On Tue, 2005-04-12 at 17:04 -0400, Tobias Luetke wrote: > Typo supports this already. > > http://blog.leetsoft.com/articles/2005/ > http://blog.leetsoft.com/articles/2005/03/ > http://blog.leetsoft.com/articles/2005/03/28/ > > On Apr 12, 2005 4:21 PM, Stuart Smith > <[EMAIL PROTECTED]> wrote: > > I misunderstood the database dependency issues; I just assumed that > > since an ISP/host would run typo against a specific persistent storage > > mechanism then a specific version of archive.rb would be installed on > > the target system. I just saw this as an extension of the multiple SQL > > files to create the initial schema for a specific vendor db. > > > > It would be interesting to see what others make of the problem regarding > > vendor specific SQL statements. There are companies that make a living > > from 'middleware' to allow the coder to write non-specific SQL (e.g. > > RogueWave had something called dbtools.h that I used a long time ago but > > that was a real 'pain in the ass' to use). > > > > Thanks > > > > Stuart > > > > > > > > app/models/archive.rb > > > > > > > > class Archive < ActiveRecord::Base > > > > > > > > has_many :articles > > > > > > > > def self.find_dates() > > > > @archives=Article.find_by_sql(["SELECT distinct date_format > > > > (created_at, '%%M %%Y') date from articles ORDER by created_at "]) > > > > end > > > > > > > > end > > > > > > > > _______________________________________________ > > Typo-list mailing list > > [email protected] > > http://rubyforge.org/mailman/listinfo/typo-list > > > >
