Class: RacePage
- Inherits:
-
Page
- Object
- Page
- RacePage
- Includes:
- WillPaginate::ViewHelpers
- Defined in:
- app/models/race_page.rb
Instance Attribute Summary collapse
-
#race ⇒ Object
Returns the value of attribute race.
-
#race_instance ⇒ Object
Returns the value of attribute race_instance.
Class Method Summary collapse
Instance Method Summary collapse
- #cache? ⇒ Boolean
- #find_by_url(url, live = true, clean = false) ⇒ Object
- #pagination ⇒ Object
- #render ⇒ Object
- #title ⇒ Object
Instance Attribute Details
#race ⇒ Object
Returns the value of attribute race.
6 7 8 |
# File 'app/models/race_page.rb', line 6 def race @race end |
#race_instance ⇒ Object
Returns the value of attribute race_instance.
6 7 8 |
# File 'app/models/race_page.rb', line 6 def race_instance @race_instance end |
Class Method Details
.sphinx_indexes ⇒ Object
8 9 10 |
# File 'app/models/race_page.rb', line 8 def self.sphinx_indexes [] end |
Instance Method Details
#cache? ⇒ Boolean
12 13 14 |
# File 'app/models/race_page.rb', line 12 def cache? true end |
#find_by_url(url, live = true, clean = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/race_page.rb', line 16 def find_by_url(url, live = true, clean = false) url = clean_url(url) if clean my_url = self.url return false unless url =~ /^#{Regexp.quote(my_url)}(.*)/ race_slug, instance_slug, subset, id = $1.split('/') if race_slug && @race = Race.find_by_slug(race_slug) if instance_slug && @race_instance = @race.instances.find_by_slug(instance_slug) if subset && id && %w{club cat p}.include?(subset) case subset when "club" @club = RaceClub.find(id) @template = 'race_clubs/show' when "cat" @category = RaceCategory.find(id) @template = 'race_categories/show' when 'p' @performance = RacePerformance.find(id) @template = 'race_performances/show' end else @template = 'race_instances/show' end else @template = 'races/show' end end self end |
#pagination ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/models/race_page.rb', line 45 def pagination p = request.params[:page] p = 1 if p.blank? || p == 0 return { :page => request.params[:page] || 1, :per_page => Radiant::Config['race_results.per_page'] || 100 } end |
#render ⇒ Object
54 55 56 |
# File 'app/models/race_page.rb', line 54 def render end |
#title ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'app/models/race_page.rb', line 58 def title if race_instance race_instance.full_name elsif race race.name else read_attribute(:title) end end |