Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #110 issue. Add :position param to Refinery::Portfolio::Admin::ItemsController #117

Merged
merged 1 commit into from
Jul 19, 2016

Conversation

gabyshev
Copy link
Contributor

The problem occurs when a user tries to add an image to existing gallery.

Started POST "/refinery/portfolio/galleries/sdsf/items" for ::1 at 2016-01-24 14:38:20 +0600
Processing by Refinery::Portfolio::Admin::ItemsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"4GEKLQc0KchJXJPA+uzwYa2OPeBr0veThNrtI9MQof0+SGKYV+uX6ld9Rgbvh6BXu83yhXT3s1UKXSDjKyZIcA==", "switch_locale"=>"en", "item"=>{"title"=>"bbb", "caption"=>"<p>bfghfg</p>", "image_id"=>"5", "gallery_id"=>"1"}, "gallery_id"=>"sdsf", "locale"=>:en}
   (0.3ms)  SELECT MAX("refinery_portfolio_items"."position") FROM "refinery_portfolio_items"
  Refinery::Authentication::Devise::User Load (0.4ms)  SELECT  "refinery_authentication_devise_users".* FROM "refinery_authentication_devise_users" WHERE "refinery_authentication_devise_users"."id" = ?  ORDER BY "refinery_authentication_devise_users"."id" ASC LIMIT 1  [["id", 1]]
  Refinery::Authentication::Devise::Role Load (0.9ms)  SELECT "refinery_authentication_devise_roles".* FROM "refinery_authentication_devise_roles" INNER JOIN "refinery_authentication_devise_roles_users" ON "refinery_authentication_devise_roles"."id" = "refinery_authentication_devise_roles_users"."role_id" WHERE "refinery_authentication_devise_roles_users"."user_id" = ?  [["user_id", 1]]
Unpermitted parameter: position

After that user sees error as described in #110 . Because app can't sort images by position in cover_image method.

# Refinery::Portfolio::Gallery
def cover_image
  items.sort_by(&:position).first if items.present?
end

@sintro
Copy link
Contributor

sintro commented Jul 12, 2016

Just faced same problem. This PR is must be merged!
For now, it is possible to temporarily solve this problem with decorator:

Refinery::Portfolio::Admin::ItemsController.prepend(Module.new do
  private
  def item_params
    params.require(:item).permit(:title, :caption, :image_id, :gallery_id, :position)
  end
end
)

@parndt parndt merged commit 305c52e into refinery:master Jul 19, 2016
@gabyshev gabyshev deleted the fix-comparison-fixnum-with-nil branch November 30, 2016 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants