Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ApplicationHelper
- def logged_in?
- session[:user_id]
- end
- def current_user
- if session[:user_id]
- return User.find(session[:user_id])
- end
- end
- end
- ------------------------------------------------
- class PatientsController < ApplicationController
- def new
- @patient = current_user.patients.new
- end
- def create
- @patient = Patient.new(params[:patient])
- if @patient.save
- flash[:notice] = "Patient Saved"
- session[:user_id] = @patient.id
- redirect_to patient_path(@patient)
- else
- flash[:notice] = "Try Again!"
- render :new
- end
- end
- def show
- @patient = Patient.find(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @patient }
- end
- # GET /products/new
- # GET /products/new.json
- end
- end
- ---------------------------------------------------------------
Add Comment
Please, Sign In to add comment