From 5f16fa8948f581eebf3635f5d36c2ac35ffa6398 Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Tue, 16 Jun 2009 01:18:42 +0200 Subject: [PATCH] using id in params --- app/controllers/albums_controller.rb | 2 +- app/controllers/collections_controller.rb | 2 +- app/models/album.rb | 3 ++- app/models/collection.rb | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index dbf6b66..ec8e73a 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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 } diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index f4bde24..7372901 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -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 } diff --git a/app/models/album.rb b/app/models/album.rb index 97997b1..fd407f4 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -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 diff --git a/app/models/collection.rb b/app/models/collection.rb index d2ec14c..97967ac 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -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)