Fix #4987: Can't populate tag string from upload url anymore.
Usage: https://danbooru.donmai.us/uploads/new?url=...&post[tag_string]=...&post[rating]=... * Pass the URL parameters from the /uploads/new page to the /uploads/:id page. * Fix the /uploads/:id page throwing an "unpermitted parameters" error when given URL params for the post edit form.
This commit is contained in:
@@ -64,7 +64,8 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@post = authorize Post.new_from_upload(permitted_attributes(Post))
|
||||
@upload_media_asset = UploadMediaAsset.find(params[:upload_media_asset_id])
|
||||
@post = authorize Post.new_from_upload(@upload_media_asset.upload, @upload_media_asset.media_asset, **permitted_attributes(Post).to_h.symbolize_keys)
|
||||
@post.save
|
||||
|
||||
if @post.errors.none?
|
||||
@@ -79,7 +80,8 @@ class PostsController < ApplicationController
|
||||
flash[:notice] = "Duplicate of post ##{@original_post.id}; merging tags"
|
||||
redirect_to @original_post
|
||||
else
|
||||
@upload = UploadMediaAsset.find(params[:post][:upload_media_asset_id]).upload
|
||||
@upload = @upload_media_asset.upload
|
||||
@media_asset = @upload_media_asset.media_asset
|
||||
flash[:notice] = @post.errors.full_messages.join("; ")
|
||||
respond_with(@post, render: { template: "uploads/show" })
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user