This is to resolve issue #85 where line 26 of the file in the controller's "new" action expects the method to return an integer so that it can find the appropriate gallery: 

https://github.com/NetsydeMiro/refinerycms-portfolio/blob/28076b7bf1f4bb7101eaddd324dee31739c4568f/app/controllers/refinery/portfolio/admin/items_controller.rb#L26

        def new
          @item = Item.new(:gallery_id => find_gallery)
        end

If the method returns an actual gallery instance, then the method bombs because gallery doesn't have a to_i conversion method.  

Because the method is never used to set an instance variable elsewhere in the controller, I preferred to reference the gallery id within the method, rather than changing the new action to something like: 

@item = Item.new(:gallery_id => find_gallery).id

which could also bomb if the find method returned nil for some reason. 

The fix was spec driven, and can be verified by executing "allows adding image via gallery's grid link (issue85: https://github.com/refinery/refinerycms-portfolio/issues/85)" in the request admin items_spec.rb: 

https://github.com/NetsydeMiro/refinerycms-portfolio/blob/2-0-stable/spec/requests/refinery/portfolio/admin/items_spec.rb#L80