Created
March 14, 2011 02:56
-
-
Save addamh/868688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StudentsController < ApplicationController | |
respond_to :html, :xml, :json | |
expose(:students) { User.where(:role => :student) } | |
expose(:student) | |
def new | |
student.role = 'student' | |
student.build_profile | |
end | |
def create | |
password = 'password' | |
options = params[:user].merge( | |
:password => password, :password_confirmation => password | |
) | |
if student.save | |
redirect_to new_student_path, :notice => "Student created!" | |
else | |
render :action => 'new' | |
end | |
end | |
def update | |
if student.update_attributes(params[:student]) | |
redirect_to(student) | |
end | |
end | |
def destroy | |
student.destroy | |
redirect_to new_student_path, :notice => "Successfully destroyed Student #{params[:id]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment