Permalink
Browse files

Fixed a table reload problem.

  • Loading branch information...
1 parent 7d50f37 commit 93273017c3151ee3a74c5c721f8cf43286bd3736 @zk committed Oct 15, 2010
Showing with 18 additions and 2 deletions.
  1. +16 −2 db/migrate/20101006031711_seo_urls.rb
  2. +2 −0 db/migrate/20101010034343_remove_lib_ns_from_var.rb
@@ -1,4 +1,18 @@
class SeoUrls < ActiveRecord::Migration
+
+ def self.make_url_friendly(name)
+ out = name.gsub("?","_q").
+ gsub("/","_").
+ gsub(" ","_").
+ downcase
+
+ if name =~ /^\.+$/
+ out = out.gsub(".", "_dot")
+ end
+
+ out
+ end
+
def self.up
add_column :libraries, :url_friendly_name, :string
add_column :functions, :url_friendly_name, :string
@@ -9,12 +23,12 @@ def self.up
Function.reset_column_information
Library.find(:all).each do |l|
- l.url_friendly_name = l.name.gsub("?","_q").gsub("/","_").gsub(" ","_").downcase
+ l.url_friendly_name = make_url_friendly(l.name)
l.save
end
Function.find(:all).each do |f|
- f.url_friendly_name = f.name.gsub("?","_q").gsub("/","_").gsub(" ","_").downcase
+ f.url_friendly_name = make_url_friendly(f.name)
f.save
end
@@ -2,6 +2,8 @@ class RemoveLibNsFromVar < ActiveRecord::Migration
def self.up
remove_column :functions, :library
remove_column :functions, :ns
+
+ Function.reset_column_information
end
def self.down

0 comments on commit 9327301

Please sign in to comment.