Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6142763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:26:01+00:00 2026-05-23T18:26:01+00:00

this is a tricky one, I hope someone can help me. I have a

  • 0

this is a tricky one, I hope someone can help me.

I have a article_set, which has many set_items, each set item has an image.
I want to create an collage of the images, so one image out of many, and save it with carrierwave.

that’s whats going on in my model:

require 'RMagick'

class ArticleSet < ActiveRecord::Base

    # ...

    after_create :create_collage  
    mount_uploader :blog_image, BlogImageUploader

    def create_collage
      # load the template
      template = Magick::Image.read("#{RAILS_ROOT}/public/images/set_template.png").first

      # go through all set items by z_index and add lay it over the template
      for item in self.set_items
        photo = Magick::Image.read(item.product.assets.first.image.url(:thumb).to_s).first
        photo.scale(item.width, item.height)
        # composite item over template offsetting pos_x and pos_y for the template border
        template.composite!(photo, item.pos_x, item.pos_y, Magick::OverCompositeOp)
      end

      # save composite image to JPG
      template.write("set_#{self.id}_#{Time.now.to_i}.jpg")

      #save and upload to s3

      self.blog_image.store!(template)
      self.blog_image = self.blog_image.store_path
      self.write_carrierwave_identifier
      self.save  

    end

end

So far, so good. I can save the set and it runs though this method, but I guess the last part

       #save and upload to s3

      self.blog_image.store!(template)
      self.blog_image = self.blog_image.store_path
      self.write_carrierwave_identifier
      self.save  

is probably incorrect, in my database I get only NULL values for blog_image.
It should, of course, contain the file name of the generated file…
any help highly appreciated.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:26:01+00:00Added an answer on May 23, 2026 at 6:26 pm

    That 3rd last line looks a bit dodgy:

    self.blog_image = self.blog_image.store_path
    

    If you remove that i’m fairly sure it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slightly tricky one here I hope the community can help me
This one has proven to be a little tricky for me so far. I
Tricky one to explain this. I have a custom built properties grid. The left
This is a bit of a tricky one. I have Document entities that are
This is a tricky one because I don't see how I can fix it
This is a tricky one, for me at least. I have a page that
Ok this is a tricky one. I have a list of Sets. I would
I hope some of you XForms gurus can help. I have a large XFroms
I hope I can explain this properly. I have a grid that is part
This is a tricky one to explain. So I'll bullet point it: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.