better tag handling. give 404 for non existing ones. link to tag.title for non-ascii chars
This commit is contained in:
parent
00e17c3e4a
commit
993df4a472
3 changed files with 8 additions and 5 deletions
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Tags</h1>
|
||||
<% for tag in @tags %>
|
||||
<%= link_to h(tag.title), tag_photos_path(tag) %>
|
||||
<%= link_to tag.title, tag_photos_path(tag.title) %>
|
||||
<% end %>
|
Loading…
Reference in a new issue