Created
March 16, 2009 19:05
-
-
Save iamjwc/80014 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Controller | |
class GuestsController < ApplicationController | |
def create | |
@guest = Guest.new(params[:guest]) | |
if @guest.save | |
redirect_to :action => 'index' | |
else | |
render :action => 'new' | |
end | |
end | |
end | |
# Model | |
class Guest | |
validates_presence_of :student_id | |
def student_name=(name) | |
student = Student.find_by_name(name) | |
self.student_id = student.id unless student.nil? | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment