Skip to content

Instantly share code, notes, and snippets.

@tonatiuh
Last active December 30, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonatiuh/7796643 to your computer and use it in GitHub Desktop.
Save tonatiuh/7796643 to your computer and use it in GitHub Desktop.
class EnglishStudentsController < ApplicationController
def update
@english_student = User.find(params[:id])
respond_to do |format|
if @english_student.update_attributes(english_student_params)
format.json { render json: { message: "Student updated successfuly" } }
else
format.json { render json: { message: "Student could not be updated" } }
end
end
end
end
User < ActiveRecord::Base
after_update :update_todays_english_attendace, if: self.level_changed?
def update_todays_english_attendace
english_attendance = english_attendances.find_by(
date: some_date,
temporary_level: false
)
english_attendance.level = level
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment