using id in params

rails2
Espen Antonsen 2009-06-16 01:18:42 +02:00
parent dde62b43d4
commit 5f16fa8948
4 changed files with 6 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class AlbumsController < ApplicationController
end
def show
@album = Album.find_by_title( params[:id])
@album = Album.find( params[:id])
respond_to do |format|
format.html
format.json { render :json => @album }

View File

@ -12,7 +12,7 @@ class CollectionsController < ApplicationController
end
def show
@collection = Collection.find_by_title( params[:id] )
@collection = Collection.find( params[:id] )
respond_to do |format|
format.html
format.json { render :json => @collection }

View File

@ -16,7 +16,8 @@ class Album < ActiveRecord::Base
named_scope :untouched, :conditions => "Albums.Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags) )"
def to_param
title.gsub(/[^a-z0-9]+/i, '-')
"#{id}-#{title.parameterize}"
#self.title.gsub(/[^a-z0-9]+/i, '-')
end

View File

@ -5,7 +5,8 @@ class Collection < ActiveRecord::Base
attr_accessor :album_list
def to_param
title.gsub(/[^a-z0-9]+/i, '-')
#title.gsub(/[^a-z0-9]+/i, '-')
"#{id}-#{title.parameterize}"
end
def album_list=(albums)