Add a localised description to the tracks

This commit is contained in:
Petko Bordjukov 2014-09-06 18:18:08 +03:00
parent 0588b48084
commit 465418cf1d
5 changed files with 28 additions and 2 deletions

View File

@ -5,6 +5,8 @@ class Track < ActiveRecord::Base
validates :name, presence: true validates :name, presence: true
validates :color, presence: true, format: {with: /\A[a-f0-9]{6}\z/i} validates :color, presence: true, format: {with: /\A[a-f0-9]{6}\z/i}
translates :name, :description
def color=(hex_triplet) def color=(hex_triplet)
write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet
end end

View File

@ -1 +1,6 @@
li = track.name li
strong
= track.name
\-
span
= track.description

View File

@ -9,6 +9,6 @@ class AddTranslationTablesToConferences < ActiveRecord::Migration
end end
def down def down
Post.drop_translation_table! :migrate_data => true Conference.drop_translation_table! :migrate_data => true
end end
end end

View File

@ -0,0 +1,5 @@
class AddDescriptionToTracks < ActiveRecord::Migration
def change
add_column :tracks, :description, :text
end
end

View File

@ -0,0 +1,14 @@
class AddTranslationTablesToTracks < ActiveRecord::Migration
def up
Track.create_translation_table!({
name: :string,
description: :text
}, {
migrate_data: true
})
end
def down
Track.drop_translation_table! migrate_data: true
end
end