8000 Make posts a nested resource in test application by deivid-rodriguez · Pull Request #5814 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Make posts a nested resource in test application #5814

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

Merged
merged 1 commit into from
Jul 25, 2019
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
6 changes: 4 additions & 2 deletions spec/support/templates_with_data/admin/posts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ActiveAdmin.register Post do
permit_params :custom_category_id, :author_id, :title, :body, :published_date, :position, :starred, taggings_attributes: [ :id, :tag_id, :name, :position, :_destroy ]

belongs_to :user

includes :author, :category, :taggings

scope :all, default: true
Expand All @@ -23,7 +25,7 @@

batch_action :set_starred, form: { starred: :checkbox } do |ids, inputs|
Post.where(id: ids).update_all(starred: inputs['starred'].present?)
redirect_to collection_path, notice: "The posts have been updated."
redirect_to collection_path(user_id: params["user_id"]), notice: "The posts have been updated."
end

index do
Expand Down Expand Up @@ -57,7 +59,7 @@
end

action_item :toggle_starred, only: :show do
link_to 'Toggle Starred', toggle_starred_admin_post_path(post), method: :put
link_to 'Toggle Starred', toggle_starred_admin_user_post_path(post.author, post), method: :put
end

show do |post|
Expand Down
4 changes: 2 additions & 2 deletions spec/support/templates_with_data/admin/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
paginated_collection(user.posts.includes(:category).order(:updated_at).page(params[:page]).per(10), download_links: false) do
table_for(collection) do
column :id do |post|
link_to post.id, admin_post_path(post)
link_to post.id, admin_user_post_path(post.author, post)
end
column :title
column :published_date
Expand All @@ -42,7 +42,7 @@
end

para do
link_to "View all posts", admin_posts_path('q[author_id_eq]' => user.id)
link_to "View all posts", admin_user_posts_path(user)
end
end
end
Expand Down
0