1

This is my code

remoti.coffe

$(document).on "change", "#post_image", (en)->
$(this).submit()

_form.haml from post

    = 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"

respond as JS

show.js.coffee

$("#posts").prepend("<%= j render 'post', post: @post%>")

render _post.haml

  .card
  .card-content
    .text-left#image_view
      = post.user.email
      =image_tag post.image(:medium)

Please help me Sorry for my english

Stephen Hines
  • 2,612
  • 1
  • 13
  • 12
Bryan Zamora
  • 131
  • 1
  • 1
  • 6

0 Answers0