diff --git a/Gemfile b/Gemfile index 09b42f4..ebfa1bd 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,8 @@ gem 'devise-kerberos-authenticatable', :git => 'git://github.com/atomaka/devise-kerberos-authenticatable.git' gem 'cancan' +gem 'enumerated_attribute' + # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index 69a4962..7cfda63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,6 +72,8 @@ GEM orm_adapter (~> 0.1) railties (~> 3.1) warden (~> 1.2.1) + enumerated_attribute (0.2.16) + meta_programming (>= 0.2.1) erubis (2.7.0) eventmachine (1.0.3) execjs (1.4.0) @@ -97,6 +99,7 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) + meta_programming (0.2.2) meta_request (0.2.3) rack-contrib railties @@ -191,6 +194,7 @@ DEPENDENCIES coffee-rails (~> 3.2.1) devise devise-kerberos-authenticatable! + enumerated_attribute jquery-rails less-rails meta_request diff --git a/app/models/alert.rb b/app/models/alert.rb index 75d7b80..7a56f50 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -1,4 +1,5 @@ class Alert < ActiveRecord::Base + enum_attr :semester, %w(US13 FS13 SS14) attr_accessible :course, :department, :semester, :sections attr_protected :user_id attr_protected :alerted diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb index 61392ec..d6ba143 100644 --- a/app/views/alerts/_form.html.erb +++ b/app/views/alerts/_form.html.erb @@ -35,7 +35,7 @@
<%= f.label :semester, :class => 'control-label' %>
- <%= f.text_field :semester, :class => 'text_field' %> + <%= f.enum_select :semester %>
diff --git a/db/migrate/20130424230817_change_alerts_semester_type.rb b/db/migrate/20130424230817_change_alerts_semester_type.rb new file mode 100644 index 0000000..82d6098 --- /dev/null +++ b/db/migrate/20130424230817_change_alerts_semester_type.rb @@ -0,0 +1,13 @@ +class ChangeAlertsSemesterType < ActiveRecord::Migration + def up + change_table :alerts do |t| + t.change :semester, :enum + end + end + + def down + change_table :alerts do |t| + t.change :semester, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 41b8f56..381e886 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,18 +11,10 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130413054153) do +ActiveRecord::Schema.define(:version => 20130424230817) do - create_table "alerts", :force => true do |t| - t.integer "user_id" - t.string "department" - t.string "course" - t.boolean "alerted", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "semester" - t.text "sections" - end +# Could not dump table "alerts" because of following StandardError +# Unknown type 'enum' for column 'semester' create_table "roles", :force => true do |t| t.string "name"