jeudi 1 mai 2014

Displaying a html view from Model Gmap


Vote count:

0




Im working on a collaborative project. Today I pulled down the updated files. One of the guys started working on displaying coordinates on a map using gmaps4rails. The weird part is he put the html in the model. The problem is I cannot add in a database call for certain model.


here are the relationships:


Chef has many meals via chef_id


Chef has one location via chef_id


Both belong to chef


Location Model:



class Location < ActiveRecord::Base
acts_as_gmappable
belongs_to :chef
validates :chef_id, :zipcode, :address, presence: true

def gmaps4rails_address
"#{address}, #{zipcode}"
end
def gmaps4rails_infowindow
"<h1>Chef: #{chef.name} </h1>" <<

"<p>Address: #{address}, #{zipcode} </p>" <<

"<h4>Meals: #{chef.meals.meal_name}</h4>"
end

end


In other views I display chefs meals by:



<% chef.meals.limit(1).each do |meal| %>

<li><%= meal.meal_name %></li>
<li>$<%= meal.price %></li>

<% end %>


How exactly do I call chef.meals in the model and pass .limit to it.



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire