Skip to content

Instantly share code, notes, and snippets.

@addamh
Created March 14, 2011 02:56
Show Gist options
  • Save addamh/868688 to your computer and use it in GitHub Desktop.
Save addamh/868688 to your computer and use it in GitHub Desktop.
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