Skip to content

Instantly share code, notes, and snippets.

@tonatiuh
Last active Dec 30, 2015
Embed
What would you like to do?
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