adding feeds into beer experiences
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@123 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
d613bf10cd
commit
6fc4b1c30e
|
@ -9,20 +9,26 @@ class ExperiencesController < ApplicationController
|
|||
# GET /experiences/1
|
||||
# GET /experiences/1.xml
|
||||
def show
|
||||
@content_title = 'Experience Points'
|
||||
@people = People.find_by_title(Page.title_from_url(params[:id]))
|
||||
cond_ary = [ 'experiences.people_id = :people_id' ]
|
||||
cond_var = { :people_id => @people.id }
|
||||
conditions = [ cond_ary.join(' AND '), cond_var ]
|
||||
@total_count = Experience.count(conditions)
|
||||
@pages, @experiences = paginate :experiences,
|
||||
:include => [ 'beer' ], :order => [ 'beers.title ASC' ],
|
||||
:per_page => per_page, :conditions => conditions
|
||||
brewery_ids = @experiences.collect { |e| e.beer.brewery_id }
|
||||
@breweries = Brewery.find(brewery_ids, :order => 'title ASC')
|
||||
flash.now[:notice] = 'No experience yet.' if @experiences.empty?
|
||||
respond_to do |format|
|
||||
format.html # index.rhtml
|
||||
format.xml { render :xml => @experiences.to_xml }
|
||||
format.html do
|
||||
cond_ary = [ 'experiences.people_id = :people_id' ]
|
||||
cond_var = { :people_id => @people.id }
|
||||
conditions = [ cond_ary.join(' AND '), cond_var ]
|
||||
@total_count = Experience.count("people_id = #{@people.id}")
|
||||
@pages, @experiences = paginate :experiences,
|
||||
:include => [ 'beer' ], :order => [ 'beers.title ASC' ],
|
||||
:per_page => per_page, :conditions => conditions
|
||||
brewery_ids = @experiences.collect { |e| e.beer.brewery_id }
|
||||
@breweries = Brewery.find(brewery_ids, :order => 'title ASC')
|
||||
flash.now[:notice] = 'No experience yet.' if @experiences.empty?
|
||||
end
|
||||
format.rss do
|
||||
@experiences = @people.experiences.find :all, :limit => per_page,
|
||||
:order => 'created_at DESC'
|
||||
render :partial => 'experiences'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title><%= @people.title -%>'s Beers</title>
|
||||
<link><%= experience_path(@people.page.title_for_url) -%></link>
|
||||
<description>Most recently added beers</description>
|
||||
<lastBuildDate><%= @experiences.first.created_at rescue '' -%></lastBuildDate>
|
||||
<% for experience in @experiences -%>
|
||||
<item>
|
||||
<title><%= experience.beer.title -%></title>
|
||||
<link><%= show_beer_link(experience.beer) -%></link>
|
||||
<description><%= experience.beer.brewery.title -%></description>
|
||||
<pubDate><%= experience.created_at -%></pubDate>
|
||||
</item>
|
||||
<% end -%>
|
||||
</channel>
|
||||
</rss>
|
|
@ -4,6 +4,7 @@ class CreateExperiences < ActiveRecord::Migration
|
|||
t.column :people_id, :integer
|
||||
t.column :beer_id, :integer
|
||||
t.column :rating, :integer
|
||||
t.column :created_at, :timestamp
|
||||
end
|
||||
add_index :experiences, :people_id
|
||||
add_index :experiences, :beer_id
|
||||
|
|
Reference in New Issue