I'm using json.jbuilder
json.array!(@posts) do |post|
json.extract! post, :id, :body, :user_id
json.image post.image.url
json.url post_url(post, format: :json)
end
And I render with js
$("#posts").prepend("<%= j render @post %>")
This is the view of the render
.col.s12.m6.l6
-if post.image.blank?
.card
.card-content
.text-left
= post.user.email
.text-left.card-content=post.body
-elsif post.body.blank?
.card
.card-content
.text-left
=post.user.email
.card-image
=image_tag post.image.url, class: "materialboxed"
-else
.card
.card-content
.text-left
=post.user.email
.card-image
=image_tag post.image.url, class: "materialboxed"
.text-left.card-content
%span= post.body
And I print it on a label
#posts
I want him to show the images but he does not show them to me, but if I put only text if he shows it in real time.