logo

Adding More Feature to Journal.Rails

Last night (yes, Sunday) I spent an hour or so adding the missing features to the Journal.Rails app. You can now search and sort by date and category.

I know what you're thinking — Wow! What's so great about that. Well, I'm happy to report it was both simple and easy to do. Just like Domino, it's not scary at all.

With the PHP version of Journal.ntf I never got round to adding search. Mainly because I didn't know how and never bothered to learn. With Rails it's easy, by nature of its architecture and took me about ten minutes to add. To see how I did it you can read this Wiki page. All I had to do was add a Search action to the Journal controller:

def search
@query = params:q
@results = Entry.search params:q, :case => :sensitive
end

Then I add a matching file called search.rhtml to the Views folder and include this rHTML:

<p>Searched for "<%= @query %>".
<% if @results.empty? %>
Nothing found</p>
<% else %>
Found <%= pluralize(@results.size, "matching entry") %>.</p>
<table>
<% for entry in @results %>
<tr>

Ordered views was a doddle and makes so much sense I worked this out myself. I added an action called "bydate" to the controller like so:

def bydate
@entry_pages, @entries = paginate :entries, 
:order_by => 'diary_date, subject', :per_page => 10
render :action => 'list'
end

Note that the last line tells the action to use the list.rhtml (default "view") to render the list of entries. We can use list.rhtml like a $$ViewTemplateDefault and then use actions to add new "view" and alter the column/sort order.

After adding the bydate action to the controller we can access the results at the URL /journal/bydate.

This is merely a few simple tweaks to the site and is just me playing around still. It's very rough. Note that I've not mimicked the Domino Categorised View feature. Because I don't like them and never use them. Categorised Views might be ok for users of a system that's trying to mimic its Notes counterpart, but nowhere else. Ever seen a categorised view on any other website? I rest my case.

Comments

  1. Jake,

    This looks great.

    I am curious, how is the security with Rails? Is it comparable to Domino login and security?

    E

  2. Is it just me, or is everybody else not seeing the /journal/bydate link in date order?

    • avatar
    • Jake
    • Mon 6 Mar 2006 07:59 AM

    Fixed it Andy. Woops.

    Erskine. I've not really got to that bit yet, but, as I understand it, it's as secure as you make it.

    • avatar
    • Kapali
    • Mon 6 Mar 2006 09:48 AM

    I am not sure about websites but I have seen categorised views with SharePoint.

    I think it allows two or three levels of categorization - there is some restriction on the number of categorization levels;not sure about it.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Mon 6 Mar 2006

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content