Created
October 20, 2011 07:08
-
-
Save chocnut/1300592 to your computer and use it in GitHub Desktop.
views
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
= form_for @nurse, do |f| | |
- @nurse.errors.full_messages.each do |msg| | |
%p= msg | |
%fieldset | |
%p | |
= f.label "Name: ",:class => 'required' | |
%br/ | |
= f.text_field :name, :id => 'name', :class => 'half' | |
%p | |
= f.label "Telephone Number: ",:class => 'required' | |
%br/ | |
= f.text_field :telephone_number, :id => 'telephone_number', :class => 'half' | |
%p | |
= f.label "Main Address: ",:class => 'required' | |
%br/ | |
= f.text_field :main_address, :id => 'main_address', :class => 'half' | |
%p | |
= f.label "Current Address: ",:class => 'required' | |
%br/ | |
= f.text_field :current_address, :id => 'current_address', :class => 'half' | |
%p | |
= f.label "Email: ",:class => 'required' | |
%br/ | |
= f.text_field :email, :id => 'email', :class => 'half' | |
%p | |
= f.label "SSN: ",:class => 'required' | |
%br/ | |
= f.text_field :ssn, :id => 'sss', :class => 'half' | |
%p | |
= f.submit "Submit", :class => 'btn btn-green big' |
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 Nurse < ActiveRecord::Base | |
validates :name, :telephone_number, :main_address, :current_address, :ssn, :presence => true | |
validates :email, :uniqueness => true, :presence => true, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i } | |
end |
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 NursesController < ApplicationController | |
def index | |
@nurses = Nurse.all | |
end | |
def new | |
@nurse = Nurse.new | |
end | |
def create | |
@nurse = Nurse.new(params[:nurse]) | |
if @nurse.save | |
flash.notice = "Successfully added nurse" | |
redirect_to :action => "index" | |
else | |
redirect_to :action => "new" | |
end | |
end | |
def destroy | |
end | |
def show | |
end | |
def update | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment