How to pass size param to carrierwave helper?

Im trying to make 1 global function to display carrier wave images in different sizes. the problem is passing the size var in method call to the carrierwave helper like below:

def get_avatar(id, size)

@profile = User.find(id).profile rescue nil
  image_tag @profile.photos.first.file_url(:img_120x145)
rescue
  image_tag ("/assets/avatars/img_#{size}.png")

end

I tried all kinds of things but are unable to pass the size var to the @profile.photos.first_url(size here).

How should one approach this?

Answers


Heres what worked for me recently.

<% image_tag @profile.photos.first.url(size) %>


Need Your Help

using a function from a string of text PHP

php

I would like to know if it is possible to store the following

Simple pure java CSV reading and parsing

java csv delimiter filereader comma

I am stuck with file reading operation and need your help.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.