ruby on rails - undefined method `model_name' for DisplayPhotoUploader:Class -
i trying loop through images display in gallery below.
<%= @venue.venue_photos.each |photo| %> <div class="col-lg-3 col-md-6 col-sm-6"> <div class="widget"> <div class="thumbnail"> <%= link_to(image_tag(photo.display_photo.url(:medium)), photo.display_photo, :class => 'thumb-zoom lightbox') %> </div> </div> </div> <% end %> am getting error while trying retrieve image url carrierwave result of looping.
undefined method `model_name' displayphotouploader:class
link_to helper creates link i.e., anchor element <a href="..">..</a> using arguments passed it. first argument used display clickable text/ image, sec argument takes set of options creates url (i.e. href) <a> element linking , lastly 1 html_options takes html attributes related <a> element.
in case, passed first , 3rd arguments correctly sec argument wrong photo.display_photo not going create url fetch attribute named display_photo of instance photo. resulting in error
undefined method 'model_name' displayphotouploader:class
to resolve this, pass valid url wish route upon clicking image.
run rake routes on command prompt check list of available routes application.
<%= link_to(image_tag(photo.display_photo.url(:medium)), photo.display_photo, :class => 'thumb-zoom lightbox') %> #### ^^^^^^^^^^^^^^^^^^^ #### alter ruby-on-rails ruby-on-rails-4 carrierwave
No comments:
Post a Comment