# Archives by Month?

**URL:** <https://www.ruby-forum.com/t/archives-by-month/64651>\
**Category:** Radiant CMS\
**Created:** [August 15, 2006, 2:12pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651 "2006-08-15T14:12:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:12pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/1 "2006-08-15T14:12:39Z")

</div>

I’m playing with Radiant on my Macbook. I installed Ruby 1.8.4, rb-  
sqlite3 and more with Darwin Ports. Then rubygem. I did gem install.  
Set up a Radiant site, edited database.yml for sqlite. Ran setup and  
selected option 3, the blog example as per the Radiant demo. Then I  
launched via Mongrel.

Well, it works. Fast and good. Lovely. Except for one thing. The  
archives works, shows a list of posts. But the Archives by Month does  
not work. I get no articles. Empty page for August 2006. Even tho’  
there clearly should be. This is with a default, unedited install.

Does anyone know of anything obvious to check?

BTW, it may be IOTTMCO but why, in the admin page edit, are Save and  
Save and Continue Editing both buttons, but Cancel is a plain link?

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:12pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/2 "2006-08-15T14:12:43Z")

</div>

On 8/10/06, Andrew B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does anyone know of anything obvious to check?
> 
> BTW, it may be IOTTMCO but why, in the admin page edit, are Save and  
> Save and Continue Editing both buttons, but Cancel is a plain link?

I don’t really know if it’s the case but in general, things that make  
changes to stuff on the server should be post-requests.

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/3 "2006-08-15T14:13:55Z")

</div>

Andrew,

Take a look at the demo site for help, specifically

\<URL: [http://demo.radiantcms.org/admin/pages/edit/10](http://demo.radiantcms.org/admin/pages/edit/10) \>

This will show you how to set up the archive page properly, including  
the proper behavior.

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/4 "2006-08-15T14:15:27Z")

</div>

On 11/08/2006, at 1:32 AM, Nathan W. wrote:

> Andrew,
> 
> Take a look at the demo site for help, specifically
> 
> \<URL: [http://demo.radiantcms.org/admin/pages/edit/10](http://demo.radiantcms.org/admin/pages/edit/10) \>
> 
> This will show you how to set up the archive page properly, including  
> the proper behavior.

I’ll certainly check there but my point was that I am running Radiant  
as downloaded and setup using setup\_database. I did not do or change  
anything else. So either: a) the download is different from the demo;  
b) something about mongrel/sqlite/my-machine is causing an issue.

No mind. I’ll work through the demo pages and compare.

thanks

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/5 "2006-08-15T14:15:33Z")

</div>

On 11/08/2006, at 7:28 AM, Nathan W. wrote:

> By a “default, unedited install” do you mean that you have added  
> nothing to the archive page itself? If so, that’s your problem … you  
> still need a bit o’ code to get things running.

I mean that I selected Option 3 in setup. There was code in the %B %Y  
Archives page that, on cursory inspection, seemed the same as that on  
the demo site.

Lets drop it for now. I’ve updated Rails and Radiant and I’m starting  
again. Which, as of last night was bombing out with Active Record  
errors.

thanks

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/6 "2006-08-15T14:15:32Z")

</div>

By a “default, unedited install” do you mean that you have added  
nothing to the archive page itself? If so, that’s your problem … you  
still need a bit o’ code to get things running.

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/7 "2006-08-15T14:15:36Z")

</div>

On 11/08/2006, at 7:50 AM, Nathan W. wrote:

> Just to make sure that I wasn’t losing it, I installed Rails 1.1.6,  
> reinstalled Radiant 0.5.1 using the gem, created a new radiant site  
> using option 3, and fired it up … it works for me.

I’ve just done the same and it doesn’t work :-(. I verified that the  
page is exactly as per the demo. I get monthly archive links in the  
sidebar for August and June, click on them, get an August 2006 page  
with no articles.

Gotta be my setup.

Oh well.

BTW, I’m also having to run under Rails 1.1.5. When I edit  
environment.rb to be 1.1.6, I get an error

```
can't activate rails (= 1.1.6), already activated rails-1.1.5]

```

(Gem::Exception)

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/8 "2006-08-15T14:15:35Z")

</div>

Just to make sure that I wasn’t losing it, I installed Rails 1.1.6,  
reinstalled Radiant 0.5.1 using the gem, created a new radiant site  
using option 3, and fired it up … it works for me.

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/9 "2006-08-15T14:15:44Z")

</div>

You didn’t happen to freeze the rails gem to your vendor directory at  
any point, did you?

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/10 "2006-08-15T14:15:48Z")

</div>

On 10/8/2006, “Nathan W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You didn’t happen to freeze the rails gem to your vendor directory at  
> any point, did you?

No. Searching around, I think it’s I think it’s because Radiant 0.5.1  
requires Rails 1.1.5.

I’ll try -u flag to unpack and then see.

thanks for all the help.

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/11 "2006-08-15T14:16:03Z")

</div>

Andrew B. wrote:

> BUT, STRFTIME(‘%m’ returns a character value, such as ‘06’, whereas  
> it’s being compared to the integer 6. I tested in sqlite3 and no rows  
> returned. Wow, 17 years of Oracle experience counts for something in  
> this Web world.
> 
> So, strftime needs to be wrapped with a string-to-integer conversion,  
> yes?

That sounds fine to me. Can you or someone else get me a unit test that  
reproduces the problem? Maybe even a patch that fixes it?

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/12 "2006-08-15T14:16:03Z")

</div>

OK, I’m new to Rails and sqlite and MySQL, so this took me half an  
hour but…

The development log showed this SQL:

SELECT \* FROM pages WHERE (pages.parent\_id = 4 AND ((((virtual = ‘f’)  
and (status\_id = 100)) AND (STRFTIME(’%m’, published\_at) = 6)) AND  
(STRFTIME(’%Y’, published\_at) = 2006))) ORDER BY published\_at DESC,  
virtual DESC, title ASC

Which I traced to the archive\_finder.rb in models. This line:

add\_condition(options, “#{extract(‘month’, ‘published\_at’)} = ?”,  
month.to\_i)

then these:

```
    when /sqlite/i
       case part
       when /year/i
         "STRFTIME('%Y', #{field})"
       when /month/i
         "STRFTIME('%m', #{field})"
       when /day/i
         "STRFTIME('%d', #{field})"
       end

```

BUT, STRFTIME(’%m’ returns a character value, such as ‘06’, whereas  
it’s being compared to the integer 6. I tested in sqlite3 and no rows  
returned. Wow, 17 years of Oracle experience counts for something in  
this Web world.

So, strftime needs to be wrapped with a string-to-integer conversion,  
yes?

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/13 "2006-08-15T14:16:05Z")

</div>

I can’t do a proper Rails unit test, because I’ve yet to even write  
my hello-world Rails app…

All I can do is tell you what I did, which is to run Radiant under  
sqlite3 and mongrel on OS X 10.4.

Sorry.

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/14 "2006-08-15T14:17:26Z")

</div>

FWIW, I think you just need to wrap the STRFTIME in a CAST:

CAST(STRFTIME(’%m’, published\_at) AS INTEGER)

But I’m still just playing around so no hurry to fix from my  
perspective.

andrew

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/15 "2006-08-15T14:16:45Z")

</div>

Andrew B. wrote:

> I can’t do a proper Rails unit test, because I’ve yet to even write  
> my hello-world Rails app…
> 
> All I can do is tell you what I did, which is to run Radiant under  
> sqlite3 and mongrel on OS X 10.4.
> 
> Sorry.

Not a problem. If someone else could verify this that would be great. If  
not, I’ll get to it when I get to it. 🙂

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![bfsog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bfsog](https://www.ruby-forum.com/u/bfsog)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/archives-by-month/64651/16 "2006-08-15T14:19:38Z")

</div>

On 11/08/2006, at 2:06 PM, John W. Long wrote:

> reproduces the problem? Maybe even a patch that fixes it?  
> The unit tests were already broken for sqlite3 in regard to this  
> problem. I just put a patch on trac [1] to solve it. I’m also running  
> on OS X (10.3.9) and sqlite3 (from darwinports).

Also there was a typo in page\_context.test.rb:

def test\_tag\_children\_each\_attributes\_with\_invalid\_limit

should be:

def test\_tag\_children\_each\_attributes\_with\_invalid\_order

I’ve put it in trac [2] so it doesn’t get forgotten 🙂

Bodhi

[1] [http://dev.radiantcms.org/radiant/ticket/257](http://dev.radiantcms.org/radiant/ticket/257)  
[2] [http://dev.radiantcms.org/radiant/ticket/258](http://dev.radiantcms.org/radiant/ticket/258)
