On 5 December 2010 11:11, Michael Baldock <[email protected]> wrote:
> Cheers for the tip Colin,
>
> "Why are you not just saying event belongs_to venue (venue has_many
> events)?"
>
> I'm still learning all the various options, and that sounds very
> interesting, I'd read about associations, and the reason I didn't use
> them this time was because I want the ability to be able to 'tweak' the
> individual values for each event ever so slightly, for example by having
> a slight variation  in longitude / latitude means that events shown on a
> map are a cluster of pins about the venue, instead of lots of pins on
> top of one another. Actually, though this could be more effectively
> implemented with a method for adding random variation, in which case
> your 'belongs_to - has_many' relationship would actually be very useful.
>
> The other consideration is that I'm downloading the data using xml, I'm
> unsure if the associated venue data will be downloaded when I retrieve
> the data about events? Any idea how to do this? or is this completed
> with
>
>      format.xml  { render :xml => @events }

I have not used render to xml so I don't know how to do it.  I can
guarantee that it is possible and google shows lots of hits.  If you
do provide lat and long offsets in the event that are to be added to
those of the venue then you will want to provide access methods in the
event model so that you can say things like @event.latitude where this
is a method of Event that fetches the venue position and adds the
offset.  You will then presumably need to put that in the xml.  A
quick bit of googling suggests you might want to use xml builder for
this but as I said I have not done such things myself so don't take my
word for it.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to