The logic here is pretty convoluted, while I don't have any direct way to tell you what you can do to make this better, but add_images_to_form doesn't really imply that it's going to render a partial or set a flash message. I think you might have too many responsibilities in this controller and perhaps you need another one since doing an image search and finishing seem like two separate control points.