Re: problems with default_url not appearing and how to get images based on conditions

17 views
Skip to first unread message

Jordan Lance

unread,
Sep 26, 2012, 7:16:09 AM9/26/12
to carri...@googlegroups.com
Nobody any idea? Is it that strange obvisious what I want to accomplish with the above 2 points ? 

On Wednesday, September 19, 2012 8:45:34 PM UTC+2, Jordan Lance wrote:

I have tried for several hours on several moments to get my carrierwave setup correctly working but haven't be able to get several issues fixed.
Hope to outline them and get some feedback on how to approach these, have extensively searched but those issues unable to fix myself. thx in advanche!

  1. Correctly loading a image version + show the default_url version when no image present.
    Using below code at this moment because default_url does not work. I call below method like show_avatar(@profile.id) from any view to display user picture.

    profile_helper.rb:
      def show_avatar(id)
        @profile = User.find(id).profile rescue nil
        image_tag @profile.photos.first.file_url(:img_112x135)
      rescue
        image_tag ("/assets/avatars/img_122x145.png")    <---- This is my default image 
      end


  2. Get image based on a condition, for example a moderated image or the "main" profile image
    My Photo model has, :moderated, :main attribute to set an image moderated or set image to be the main profile picture, to display in search results.
    Unable to figure out how to get image based on condition.
    profile_helper.rb

  3. def show_main_avatar(id) 
    @main = Photo.where(:attachable_id => id, :attachable_type => "Profile", :main => true).first
    < get the image based on these criteria somehow, but how?>








Reply all
Reply to author
Forward
0 new messages