Permalink
Browse files

Migrated from permalink_fu to friendly_id as permalink_fu is not bein…

…g updated anymore.

Also, as of new Rails versions, Psych YAML engine doesn't play well with permalink_fu, so it's a need.
  • Loading branch information...
1 parent 36ce5f0 commit 79e22633344b4c7b5b06c04be903cc24cd91fbb9 @brodock brodock committed Dec 22, 2011
View
@@ -9,7 +9,7 @@ gem 'RedCloth', :require => "redcloth"
gem 'acts_as_list'
gem 'acts_as_state_machine'
-gem 'permalink_fu'
+gem 'friendly_id', '~>4.0.0.rc2'
group :development, :test do
gem 'rspec-rails'
View
@@ -48,6 +48,7 @@ GEM
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
+ friendly_id (4.0.0.rc2)
highline (1.6.1)
i18n (0.5.0)
json (1.6.3)
@@ -58,7 +59,6 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
mysql2 (0.2.7)
- permalink_fu (1.0.0)
polyglot (0.3.3)
rack (1.2.4)
rack-mount (0.6.14)
@@ -119,9 +119,9 @@ DEPENDENCIES
acts_as_state_machine
autotest
bluecloth
+ friendly_id (~> 4.0.0.rc2)
highline
mysql2 (~> 0.2.7)
- permalink_fu
rack-openid
rails (~> 3.0.7)
rails3-generators
@@ -92,7 +92,7 @@ def destroy
protected
def find_forum
- @forum = current_site.forums.find_by_permalink!(params[:id])
+ @forum = current_site.forums.find(params[:id])
end
end
@@ -78,8 +78,8 @@ def find_parents
if params[:user_id]
@parent = @user = User.find(params[:user_id])
elsif params[:forum_id]
- @parent = @forum = Forum.find_by_permalink(params[:forum_id])
- @parent = @topic = @forum.topics.find_by_permalink(params[:topic_id]) if params[:topic_id]
+ @parent = @forum = Forum.find(params[:forum_id])
+ @parent = @topic = @forum.topics.find(params[:topic_id]) if params[:topic_id]
end
end
@@ -80,10 +80,10 @@ def destroy
protected
def find_forum
- @forum = current_site.forums.find_by_permalink!(params[:forum_id])
+ @forum = current_site.forums.find(params[:forum_id])
end
def find_topic
- @topic = @forum.topics.find_by_permalink!(params[:id])
+ @topic = @forum.topics.find(params[:id])
end
end
View
@@ -7,7 +7,8 @@ class Forum < ActiveRecord::Base
belongs_to :site
- has_permalink :name
+ extend FriendlyId
+ friendly_id :name, :use => :slugged, :slug_column => :permalink
attr_readonly :posts_count, :topics_count
View
@@ -36,7 +36,8 @@ class Topic < ActiveRecord::Base
attr_readonly :posts_count, :hits
- has_permalink :title, :scope => :forum_id
+ extend FriendlyId
+ friendly_id :title, :use => :scoped, :slug_column => :permalink, :scope => :forum
def to_s
title
View
@@ -18,7 +18,8 @@ def moderatable
has_many :monitorships, :dependent => :delete_all
has_many :monitored_topics, :through => :monitorships, :source => :topic, :conditions => {"#{Monitorship.table_name}.active" => true}
- has_permalink :login, :scope => :site_id
+ extend FriendlyId
+ friendly_id :login, :use => :scoped, :slug_column => :permalink, :scope => :site
attr_readonly :posts_count, :last_seen_at
View
@@ -1,3 +1,4 @@
+# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -93,9 +93,9 @@
protected
def stub_topic!
- Forum.stub!(:find_by_permalink).with(@forum.to_param).and_return(@forum)
+ Forum.stub!(:find).with(@forum.to_param).and_return(@forum)
@forum.stub!(:topics).and_return([])
- @forum.topics.should_receive(:find_by_permalink).with(@topic.to_param).and_return(@topic)
+ @forum.topics.should_receive(:find).with(@topic.to_param).and_return(@topic)
end
end

0 comments on commit 79e2263

Please sign in to comment.