在这里 在模型中
has_attached_file :image, styles: { medium: "250" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
_comment.html.erb 中的
<% if !comment.image.url(:medium) == '/images/medium/missing.png' %>
<img src="<%= comment.image.url(:medium) %>">
<% end %>
像我说的那样,只有当我包含图像时它才会返回错误
PS。我确实迁移并重新启动了服务器
有什么想法吗?谢谢!
ERROR
ActionController::UnknownFormat
并突出显示对评论控制器
中的创建操作中的格式作出响应 def create
if params[:comment][:parent_id].present?
@comment = Comment.find(params[:comment][:parent_id]).replies.build(comment_params)
#@comment = @post.comments.create(comment_params)
@comment.user = current_user
@comment_parent = Comment.find(params[:comment][:parent_id]).user
@post = Post.find_by_id(params[:comment][:post_id])
puts 'ffffffffffffffffffffffffffffff'
puts @post
puts 'ffffffffffffffffffffffffffffffddddd'
elsif params[:comment][:parent_id].blank?
@post = Post.find(params[:post_id])
@comment = @post.comments.create(comment_params)
@comment.user = current_user # I ADDED THE @POST
@comment.create_activity :create, owner: current_user, key: 'commenting', recipient: @comment.post.user
end
@comment.save
@comment.body.scan(/@(\w+)/).flatten.to_a.each do|username|
@mentioned = User.find_by_username(username)
if !@mentioned.blank?
@comment.body = username
@comment.save
@comment_body = @comment.body
@comment2 = @comment
@comment2.create_activity :create, recipient: @mentioned, key: 'mentioning'
puts @comment_body
mentioned_id = @mentioned.id
mentioned_username = @mentioned.username
@comment.body.gsub!(username, '<a class="mentioned" href="/user/' + mentioned_username.to_s + '">@' + mentioned_username.to_s + '</a>')
@comment.save
puts @comment_body
end
end
if @comment.save
respond_to do |format|
#format.html
format.js
end
end
端