From c42a7fbfb51465126001769c60f8b304ea800e4d Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 3 Apr 2013 19:44:01 -0400 Subject: [PATCH] Add semester field to alerts --- app/models/alert.rb | 3 ++- app/views/alerts/_form.html.erb | 6 +++++ app/views/alerts/index.html.erb | 2 ++ app/views/alerts/show.html.erb | 2 ++ .../20130403233851_add_semester_to_alerts.rb | 5 ++++ db/schema.rb | 26 +++++++++++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130403233851_add_semester_to_alerts.rb create mode 100644 db/schema.rb diff --git a/app/models/alert.rb b/app/models/alert.rb index 0355da9..c47613a 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -1,5 +1,5 @@ class Alert < ActiveRecord::Base - attr_accessible :alerted, :course, :department, :user_id + attr_accessible :alerted, :course, :department, :user_id, :semester validates :department, :presence => true, :length => { @@ -21,6 +21,7 @@ class Alert < ActiveRecord::Base :numericality => { only_integer: true } + validates :semester, :presence => true def alerted? @alerted diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb index d5ed1b0..758bfe6 100644 --- a/app/views/alerts/_form.html.erb +++ b/app/views/alerts/_form.html.erb @@ -17,6 +17,12 @@ <%= f.text_field :course, :class => 'text_field' %> +
+ <%= f.label :semester, :class => 'control-label' %> +
+ <%= f.text_field :semester, :class => 'text_field' %> +
+
<%= f.label :alerted, :class => 'control-label' %>
diff --git a/app/views/alerts/index.html.erb b/app/views/alerts/index.html.erb index 54b56cc..91bde26 100644 --- a/app/views/alerts/index.html.erb +++ b/app/views/alerts/index.html.erb @@ -9,6 +9,7 @@ <%= model_class.human_attribute_name(:user_id) %> <%= model_class.human_attribute_name(:department) %> <%= model_class.human_attribute_name(:course) %> + <%= model_class.human_attribute_name(:semester) %> <%= model_class.human_attribute_name(:alerted) %> <%= model_class.human_attribute_name(:created_at) %> <%=t '.actions', :default => t("helpers.actions") %> @@ -21,6 +22,7 @@ <%= alert.user_id %> <%= alert.department %> <%= alert.course %> + <%= alert.semester %> <%= alert.alerted %> <%=l alert.created_at %> diff --git a/app/views/alerts/show.html.erb b/app/views/alerts/show.html.erb index 86cce4f..a77d25a 100644 --- a/app/views/alerts/show.html.erb +++ b/app/views/alerts/show.html.erb @@ -10,6 +10,8 @@
<%= @alert.department %>
<%= model_class.human_attribute_name(:course) %>:
<%= @alert.course %>
+
<%= model_class.human_attribute_name(:semester) %>:
+
<%= @alert.semester %>
<%= model_class.human_attribute_name(:alerted) %>:
<%= @alert.alerted %>
diff --git a/db/migrate/20130403233851_add_semester_to_alerts.rb b/db/migrate/20130403233851_add_semester_to_alerts.rb new file mode 100644 index 0000000..32870e7 --- /dev/null +++ b/db/migrate/20130403233851_add_semester_to_alerts.rb @@ -0,0 +1,5 @@ +class AddSemesterToAlerts < ActiveRecord::Migration + def change + add_column :alerts, :semester, :string + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..3bde7ac --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,26 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20130403233851) do + + create_table "alerts", :force => true do |t| + t.integer "user_id" + t.string "department" + t.string "course" + t.boolean "alerted" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "semester" + end + +end