Hi Jonlee,

At first sight, all I have to say is that your Location model could be 
greatly simplified with the use of the geocoder 
<https://github.com/alexreisner/geocoder> gem. It provides great 
functionalities when dealing with GPS coordinates, especially computing 
distances or searching within a given area.

Hope this helps :)

Philippe

Le mercredi 25 juin 2014 19:09:21 UTC+2, Jonlee Peakman a écrit :
>
> I have a feeling I am gonna get my ass kicked here, but this is my first 
> attempt at creating real life model logic
>
> I have 3 models: 
>
>   Trader - 
> https://github.com/JonleePeakman/locations/blob/master/app/models/trader.rb
>  
>
>   Service -
> https://github.com/JonleePeakman/locations/blob/master/app/models/service.rb
>  
>
>   Location -
> https://github.com/JonleePeakman/locations/blob/master/app/models/location.rb
>
>
> and my DB Schema is: 
> https://github.com/JonleePeakman/locations/blob/master/db/schema.rb
>
>
> This is all I have at the moment and it does exactly what I want it to do. 
>  I will plan on my controller and views later but I want to pause and 
> review on my work and could use some help as I am unsure if I am overusing 
> callbacks especially in the Service model and what I could do otherwise.
>
>
> A quick overview of the plan is:
>
> A Trader has and belongs to many Locations and vice-versa, and a Trader 
> has many Services each of which have a range.  This range is the distance a 
> trader may travel to provide the service from their central post_code e.g. 
> a builder might travel 20 miles to build a porch but would travel 50 miles 
> for a customer to build a full house extension.  Therefore the Locations 
> for a Trader all hinge on the maximum range of their Services.  
>
>
> The Locations table is populated with UK postcode data with Lat/Lon 
> coordinates and all distances and ranges are calculated using the Haversine 
> formula.
>
>
> The plan is when a User visits the website they enter their post code, 
> firstly all Traders in the Location will be identified.  Then When the user 
> clicks on a specific Trader, the Trader=>'services_in' function will be 
> called to only show the services that the trader provides within their post 
> code.
>
>
> I hope that makes sense and you have a little time to peruse the models, I 
> could really do with having a discussion on what I have created so far to 
> see how smelly my code is.  As I say I have never done anything to this 
> level before.
>
>
> much regards
>
>
> JL
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6f90f0bc-c263-4075-9c36-f2e002af882e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to