ruby on rails - Image in related record won't display on index page -


i have 2 tables, 1 of venuetypes , 1 of mapicons. venuetype belongs mapicon.

each mapicon has name , image uploaded paperclip.

when view venuetype record have associated mapicon displayed using bit of code:

<%= image_tag @venuetype.mapicon.mapicon.url(:mapicon) %> 

i have table of venues each venue belongs venuetype.

however when view venue record on index page mapicon doesn't display image, shows blank div properties set in css class.

this code im using atempt display mapicon:

<div id="venue_map_icon_<%= venue.id %>" style="position:absolute;" <%= image_tag (venue.venuetype.mapicon.mapicon.url(:mapicon)), :class => "mapicon" %></div> 

i hope question makes sense, wil try clarify if needed, appreciated!

edit

mapicon model

class mapicon < activerecord::base   has_many :venuetypes   has_attached_file :mapicon,     :styles => {       :mapicon => "20x20" } end 

venuetype model

class venuetype < activerecord::base   has_many :venues   belongs_to :mapicon   has_attached_file :icon,     :styles => {       :thumb=> "100x100>",       :small  => "150x150>",       :medium => "300x300>",       :large =>   "400x400>" },       :default_url => '/images/noimage.png' end 

venue model

class venue < activerecord::base   attr_accessible :name, :addressline1, :addressline2, :addressline3, :addressline4, :postcode, :phonenumber, :about, :icontoppx, :iconleftpx, :area_id, :venuetype_id, :lat, :long, :venuephotos_attributes   belongs_to :area   belongs_to :venuetype   has_many :reviews   has_many :venuephotos    accepts_nested_attributes_for :venuephotos, :allow_destroy => true    scope :with_type, lambda { |types|     types.present? ? where(:venuetype_id => types) : scoped }    scope :with_area, lambda { |areas|     areas.present? ? where(:area_id => areas) : scoped }    def to_param     "#{id}-#{name.gsub(/\w/, '-').downcase}"   end end 

gah! think see it, if we'll kicking ourselves...

your view tags jumbled:

<div id="venue_map_icon_<%= venue.id %>" style="position:absolute;" <%= image_tag (venue.venuetype.mapicon.mapicon.url(:mapicon)), :class => "mapicon" %></div>

it's missing closing ">" on first div, , closing parentheses on image_tag call misplaced. should after "mapicon", such:

<div id="venue_map_icon_<%= venue.id %>" style="position:absolute;"> <%= image_tag(venue.venuetype.mapicon.mapicon.url(:mapicon), :class => "mapicon") %> </div> 

unless "mapicon" class supposed on div, in case this:

<div id="venue_map_icon_<%= venue.id %>" style="position:absolute;" class="mapicon"> <%= image_tag(venue.venuetype.mapicon.mapicon.url(:mapicon)) %> </div> 

i think single-line horizontal scroll display messed head , prevented me seeing it. when saw workaround in paragraph form, jumped right out @ me.

hope it. :)


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -