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 permitted_param generation for belongs_to when :param is used #6460

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions features/belongs_to.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ Feature: Belongs To
When I press "Update Post"
Then I should see "Post was successfully updated."

Scenario: Updating a child resource page with custom configuration
Given a configuration of:
"""
ActiveAdmin.register User
ActiveAdmin.register Post do
belongs_to :author, class_name: "User", param: "user_id", route_name: "user"
permit_params :title

form do |f|
f.actions
end
end
"""
When I go to the last author's last post page
And I follow "Edit Post"
Then I should see the element "form[action='/admin/users/2/posts/2']"
And I should see a link to "Hello World" in the breadcrumb

When I press "Update Post"
Then I should see "Post was successfully updated."

Scenario: Creating a child resource page
Given a configuration of:
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/resource/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def required?
end

def to_param
:"#{@target_name}_id"
(@options[:param] || "#{@target_name}_id").to_sym
end
end
end
Expand Down