diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index a9f0ccb..909d157 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -4,11 +4,14 @@ class PhotosController < ApplicationController def index if params[:tag_id] && params[:album_id] - @photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :conditions => ['photos.album_id = :album', {:album => Album.find(params[:album_id] ) } ], :order => "photos.id ASC") + @tag = Tag.find_by_title!( params[:tag_id] ) + @photos = @tag.photos.find(:all, :conditions => ['photos.album_id = :album', {:album => Album.find(params[:album_id] ) } ], :order => "photos.id ASC") elsif params[:tag_id] - @photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :order => "photos.id ASC") + @tag = Tag.find_by_title!( params[:tag_id] ) + @photos = @tag.photos.find(:all, :order => "photos.id ASC") elsif params[:album_id] - @photos = Album.find( params[:album_id]).photos.find(:all, :order => "photos.id ASC") + @album = Album.find( params[:album_id]) + @photos = @album.photos.find(:all, :order => "photos.id ASC") elsif params[:q] #search = params[:q] #search = search.split("AND").map{|q|q.strip} diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6d8c194..391fea7 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -5,7 +5,7 @@ class TagsController < ApplicationController if params[:album_id] @tags = Album.find( params[:album_id] ).photo_tags else - @tags = Tag.find( :all, :order => 'title') + @tags = Tag.order('title') end respond_to do |format| format.html diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 9695c93..bca7cd7 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -1,4 +1,4 @@

Tags

<% for tag in @tags %> -<%= link_to h(tag.title), tag_photos_path(tag) %>  +<%= link_to tag.title, tag_photos_path(tag.title) %>  <% end %> \ No newline at end of file