Permalink
Browse files

Allow each user to specify their own keywords for the links they subm…

…it - even if another user has already submitted the link.
  • Loading branch information...
1 parent f05151e commit 02b8be440bf09f6cdfd29ae79bbea8a97e5e30e4 @leenookx committed Feb 25, 2011
@@ -111,6 +111,7 @@ def create
userlink = UserLink.new
userlink.user_id = user.id
userlink.link_id = link.id
+ userlink.keywords = params[:links][:keywords]
userlink.save
flash[:notice] = 'Link was successfully created.'
@@ -0,0 +1,9 @@
+class AddKeywordToUserLinks < ActiveRecord::Migration
+ def self.up
+ add_column :user_links, :keywords, :string
+ end
+
+ def self.down
+ remove_column :users_links, :keywords
+ end
+end
@@ -0,0 +1,8 @@
+class CopyLinkKeywordsToUserLinks < ActiveRecord::Migration
+ def self.up
+ execute "update user_links set keywords = (select keywords from links where links.id = user_links.link_id)"
+ end
+
+ def self.down
+ end
+end
@@ -0,0 +1,9 @@
+class RemoveKeywordsFromLinks < ActiveRecord::Migration
+ def self.up
+ remove_column :links, :keywords
+ end
+
+ def self.down
+ add_column :links, :keywords, :string
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110102130628) do
+ActiveRecord::Schema.define(:version => 20110225215621) do
create_table "activations", :force => true do |t|
t.string "code", :null => false
@@ -68,7 +68,6 @@
create_table "links", :force => true do |t|
t.text "url", :null => false
t.text "description"
- t.string "keywords"
t.integer "status", :default => 0
t.datetime "created_at"
t.datetime "updated_at"
@@ -101,6 +100,7 @@
t.integer "link_id"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "keywords"
end
create_table "users", :force => true do |t|

0 comments on commit 02b8be4

Please sign in to comment.