Archive for August, 2006

Here is a method by mixonix to create pagination links by link_to_remote. Copy this code in your helpers/application_helper.rb

def ajax_pagination_links(paginator, options={})

options.merge!(ActionView::Helpers::PaginationHelper::DEFAULT_OPTIONS) {|key, old, new| old}
window_pages = paginator.current.window(options[:window_size]).pages
return if window_pages.length <= 1 unless
options[:link_to_current_page]

first, last = paginator.first, paginator.last

returning html = ” do
[...]

Wednesday, August 16th, 2006 | No Comments

Those who wants to include simple 5 star rating mechanism in their ROR application.Can include a couple of functions in their helper to provide a form a rating field and display the result.Of course no 1/2 ratings can be achieved through this way. One needs to include the below given two function to some helper. [...]

Monday, August 14th, 2006 | No Comments

The situation was: running Ruby 1.8.4, Rails 1.1.2, on WinXP & WEBrick server.
My application was working fine, but as I installed Rmagick my application crashed.
I got strange errors like:
compile error /script/../config/../app/views/layouts/application.rhtml:18: parse error, unexpected $, expecting kEND
if I refresh again the error actually changes(further refreshes flip back & forth between errors):
compile error
/script/../config/../app/views/layouts/application.rhtml:18: Invalid char `01′ [...]

Thursday, August 10th, 2006 | 1 Comment

Ajaxified tree comes with the following features
1.) Containing the ajax links for the tree items using link_to_remote
2.) Highlighting the selected node of the tree and other custom effects.
3.) Two way syncronization between the tree nodes and the currently displayed item on the web-page.
4.) Supports the tree architecture provided by the acts_as_tree.
5.) Clear and self traversing [...]

Wednesday, August 9th, 2006 | No Comments

I was surprised as there is no function in ruby to convert all newline characters to <br>.
Here is a php nl2br equivalent method to convert all newline characters (\n) to break tag (<br>) in a string.
def nl2br(s)
s.gsub(/\n/, ‘<br>’)
end

Monday, August 7th, 2006 | No Comments