javascript - Pull post image in rails display in div -
i've created js grid , i'm trying pull logo image , display in div data-thumbnail
how add together link pull post images?
<%- model_class = post -%> <div class="spacer spacer-big"></div> <div class="container" style="padding-right:50px;padding-left:50px;"> <div id="grid"> <div class="box"> <div data-thumbnail= "trying post logo here" </div> i inserted <%=image_tag post.logoimage.url %> between quotation marks i'm still getting error.
fix
you'll need this:
<%= content_tag :div, "", data: { thumbnail: @post.logoimage.url } %> here's info on content_tag you
this should accompanied next controller action:
#app/controllers/your_controller.rb class yourcontroller < applicationcontroller def action @post = post.first #-> sets post object end end --
data
the error receive follows:
undefined local variable or method `post'
this means view calling non-existent object (variable) (post). solution create sure post set correctly. , this, need either utilize controller (as per rails' mvc pattern, or set in view:
<% post = post.first %> <%= content_tag :div, "", data: { thumbnail: @post.logoimage.url } %> javascript jquery html css ruby-on-rails
No comments:
Post a Comment