Browse files

User & Student changes

* Modified migrations to force the status to be 'active' in new columns
* Corrected more instances of the find_homerooms() method.
  • Loading branch information...
1 parent e86197b commit fe3043d2d8b3222424444631259d64696dfbba36 @rnhurt committed Aug 21, 2010
Showing with 14 additions and 9 deletions.
  1. +6 −8 app/controllers/users/students_controller.rb
  2. +1 −1 app/models/student.rb
  3. +7 −0 db/migrate/024_add_active_flags.rb
View
14 app/controllers/users/students_controller.rb
@@ -25,21 +25,21 @@ def show
def new
@student = Student.new
- @homerooms = Student.find_homerooms()
+ @homerooms = Student.homerooms.active
render :action => :edit
end
def edit
@student = Student.find(params[:id])
- @homerooms = Student.find_homerooms()
+ @homerooms = Student.homerooms
end
def create
@student = Student.new(params[:student])
- @homerooms = Student.find_homerooms()
+ @homerooms = Student.homerooms
respond_to do |format|
if @student.save
@@ -57,16 +57,14 @@ def create
def update
@student = Student.find(params[:id])
- ## If an alternate HOMEROOM is provided then use it instead
- if !params[:homeroom1].empty?
- params[:student][:homeroom] = params[:homeroom1]
- end
+ ## If an alternate HOMEROOM is provided then use it instead
+ params[:student][:homeroom] = params[:homeroom1] if !params[:homeroom1].empty?
if @student.update_attributes(params[:student])
flash[:notice] = "Student '" + @student.full_name + "' was successfully updated."
redirect_to students_url
else
- @homerooms = Student.find_homerooms()
+ @homerooms = Student.homerooms.active
render :action => "edit"
end
end
View
2 app/models/student.rb
@@ -17,7 +17,7 @@ class Student < User
:in => from_year..to_year,
:message => "must be in the range of #{from_year} to #{to_year}"
- named_scope :homerooms, :select => 'DISTINCT homeroom name', :conditions => {:active => true}
+ named_scope :homerooms, :select => 'DISTINCT homeroom', :conditions => {:active => true}
named_scope :sorted, :order => 'last_name ASC'
def current_course_terms
View
7 db/migrate/024_add_active_flags.rb
@@ -1,9 +1,16 @@
class AddActiveFlags < ActiveRecord::Migration
def self.up
+ # Add the new 'active' columns
add_column :users, :active, :boolean, :default => true
add_column :assignments, :active, :boolean, :default => true
add_column :assignment_categories, :active, :boolean, :default => true
add_column :sites, :active, :boolean, :default => true
+
+ # Make everything active!
+ execute "UPDATE users SET active = 't';"
+ execute "UPDATE assignments SET active = 't';"
+ execute "UPDATE assignment_categories SET active = 't';"
+ execute "UPDATE sites SET active = 't';"
end
def self.down

0 comments on commit fe3043d

Please sign in to comment.