Archive for the ‘Uncategorized’ Category

Currency converter in Rails

February 17, 2008

Recently I was searching for a library in Rails, which can be used as currency converter app. After searching the blogs and rubyforge I decided to write it on my own :) . For me its working perfectly however I am open for your feedback on the same. Feel free to use it for your rails development and share your experience.

This can be downloaded from rubyforge at http://rubyforge.org/projects/curr-converter/

If this link doesn’t work for you , feel free to send me a message

Ajax Pagination

August 26, 2007

This pagination facilates retrieving of photos from database with AJAX.

1.Create partial in views.Add following code to it.

0), :update => “your div id“,
:url => {:action => :imgstrip, :id => post, :skip => ([0,skip.to_i-1].max) } if post.medias.size>4 –>

=0
break if (cnt+=1)==5
–>

0), :update => “your div id“,
:url => {:action => ‘action‘, :id => post, :skip => ([0,[skip.to_i+1,post.medias.size-4].min].max) }if post.medias.size>4 –>

Replace “post” with “your object

2.To render template add following line to views

render :partial => ‘template‘, :locals => { :post => post, :skip => params[:skip] }

3.Add following in controller.rb

def action
post = Post.find params[:id]
render :partial => ‘template’ :locals => { :post => post, :skip => params[:skip] }
end

Replace ‘template’ with your view name.
This will show four photos after each scroll.

Thanks

Naveen Joshi