Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4093080
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:34:23+00:00 2026-05-20T19:34:23+00:00

I’m super new to rails and javascript, I have a table of venues with

  • 0

I’m super new to rails and javascript, I have a table of venues with each belonging to a type and an area. They are displayed as partials on the index page and also each has its own icon on a map to the left of the screen.

I have just added a new table of mapicons which just holds an image uploaded using paperclip to my app so each venuetype has a differant icon. This all works fine however the javascript I was using to place the icons on the map breaks when I include the new mapicon.

working mapicon placement (_venue.html.erb)

<%= link_to venue do %>
  <div class="venue_partial">    
    <span class="venue_partial_name"><%= venue.name %></span>    
    <div id="venue_map_icon_<%= venue.id %>" class="venue_map_icon" style="position:absolute;"></div>
  </div>
<% end %>

<script type="text/javascript">
  document.getElementById("venue_map_icon_<%= venue.id %>").style.left= "<%= venue.iconleftpx %>px";
  document.getElementById("venue_map_icon_<%= venue.id %>").style.top= "<%= venue.icontoppx %>px";
</script>

Displays the map icon correctly on the map but as black stars as I have set in the css.

broken mapicon placement (_venue.html.erb)

<%= link_to venue do %>
  <div class="venue_partial">    
    <span class="venue_partial_name"><%= venue.name %></span>    
    <div id="venue_map_icon_<%= venue.id %>" <%= image_tag venue.venuetype.mapicon.mapicon.url(:mapicon), :style => "position:absolute;", :class => "venue_map_icon" %></div>
  </div>
<% end %>

<script type="text/javascript">
  document.getElementById("venue_map_icon_<%= venue.id %>").style.left= "<%= venue.iconleftpx %>px";
  document.getElementById("venue_map_icon_<%= venue.id %>").style.top= "<%= venue.icontoppx %>px";
</script> 

Displays the correct mapicons that I uploaded and assigned to each venuetype but they are positioned at the top right corner of their venue partial and not on the map to the left of the screen.

Hope I’ve asked this well, any clarification needed please ask. Thanks for any help its much appreciated!

EDIT

Heres a couple of screenshots I hope will help, The first is how the mapicons are currently. The venue partials show as Tester1, Tester2 etc with a large coloured icon to the left of the name, the grayed lettering under the name is the type (Type 1, 2 or 3). And the map icons are the black stars to the left positioned absolutely with the top and left values taken from their respective venue records.

enter image description here

The second screenshot is when I change the code as shown above, the partials show the same but the mapicons instead of being black stars show correctly as smaller coloured squares but aren’t positioning correctly. They are sticking to the top right corner of their own venue partials.

enter image description here

This is what I want it to display as: (this is a mocked-up image)

enter image description here

The CSS for the mapicons is just:

.venue_map_icon {
width: 19px;
height: 18px;
padding: none;
margin: none;
background-image:url(/images/mapicon.png);
border: none;
}

  .venue_map_icon:hover {
  background-image:url(/images/mapicon_hover.png);
  }

Model relationships

Venues

class Venue < ActiveRecord::Base
  belongs_to :venuetype
end

Venuetypes

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

Mapicons

class Mapicon < ActiveRecord::Base
  has_many :venuetypes
  has_attached_file :mapicon,
    :styles => { 
      :large => "640x480", 
      :medium => "300x300", 
      :thumb => "100x100", 
      :mapicon => "20x20" }
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:34:23+00:00Added an answer on May 20, 2026 at 7:34 pm

    I found my error!

    What was:

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

    Should be:

    <div id="venue_map_icon_<%= venue.id %>" style="position:absolute;" <%= image_tag (venue.venuetype.mapicon.mapicon.url(:mapicon)), :class => "venue_map_icon" %></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.