这是我的代码
remoti.coffe
$(document).on "change", "#post_image", (en)->
$(this).submit()
来自帖子的_form.haml
= form_for @post, remote:true do |f|
- if @post.errors.any?
#error_explanation
%h2= "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:"
%ul
- @post.errors.full_messages.each do |msg|
%li= msg
.input-field
= f.file_field :image
.input-field
= f.text_area :body, class: "materialize-textarea", rows: "1"
= f.label :body, "Comparte con la comunidad"
.actions
= f.submit 'Publicar', class: "btn waves-effect waves-light deep-orange accent-2 right"
以JS回复
show.js.coffee
$("#posts").prepend("<%= j render 'post', post: @post%>")
渲染_post.haml
.card
.card-content
.text-left#image_view
= post.user.email
=image_tag post.image(:medium)
请帮帮我 对不起我的英文