How to find index of records rendered by a partial with collection in Rails

Using render partial with collection how to find the index of the records?

Somewhere I found that someone is commented like,
“It seems this is an undocumented feature of rails.”

Anyway we can find this by using ‘recordName_counter’.

Render a partial with collection


= render :partial = > "person", :collection => @winners
Name: = person.name 

In Partial write


  Rank: = person_counter + 1
  Name: = person.name 

Result


Rank: 1 Name: Peter
Rank: 2 Name: Paul
Rank: 3 Name: Mary

Advertisement

Details about Rails paperclip error: ‘There was an error processing the thumbnail for paperclip-reprocess’

I got this error while working with paperclip. The project was stable and I have no idea why this error happens at this point of time.

[paperclip] An error was received while processing: #
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for paperclip-reprocess20110822-2281-19969sz

So I was lazy to fix the error, and find that I have no imagemagick installed in my new system. After installing ‘imagemagick’ it got fixed.

$ sudo apt-get update
$ sudo apt-get install imagemagick --fix-missing

Install Rails 3.2 using rvm on redhat

Upgrade Packages

yum update

Installing Recommended Packages

yum install gcc-c++ patch readline readline-devel zlib zlib-devel 
yum install libyaml-devel libffi-devel openssl-devel make 
yum install bzip2 autoconf automake libtool bison iconv-devel

Install RVM ( Ruby Version Manager )

$ curl -L get.rvm.io | bash -s stable

Install Required Ruby Version

$ rvm install 1.9.3

Install rails

$ gem install rails --version '3.2.19'