Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1041613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:22:49+00:00 2026-05-16T15:22:49+00:00

Sorry i really didn’t know how to phrase the question any better but here

  • 0

Sorry i really didn’t know how to phrase the question any better but here is my problem:

when i try to update or create a patient object in my rails application the values are not getting sent through to the model, because when i try to create a new patient i get validation errors that i put in place sating i have to enter values (which i did), and when i update an existing patient object the values don’t change even though i get the message of “successfully updated patient”

any ideas why that might be?

it used to work fine and i didn’t change anything in the patient controller or model for it to stop working?

if you need any code from me please just let me know what u need.

controller create and update code:

class PatientsController < ApplicationController

  before_filter :require_user
  load_and_authorize_resource

  def new
    @patient = Patient.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @patient }
    end
  end

  def edit
    @patient = Patient.find(params[:id])
  end

  def create
    @patient = Patient.new(params[:patient])
    respond_to do |format|
      if @patient.save
        format.html { redirect_to(@patient, :notice => 'Patient was successfully created.') }
      else
        format.html { render :action => "new" }
      end
    end
  end

  def update
    @patient = Patient.find(params[:id])
    respond_to do |format|
      if @patient.update_attributes(params[:patient])
        format.html { redirect_to(@patient, :notice => 'Patient was successfully updated.') }
      else
        format.html { render :action => "edit" }
      end
    end
  end

end

server Log:

  Parameters: {"commit"=>"Update", "authenticity_token"=>"7ypFp3DhLokjvqau06+EOOoEU2T/7UmU5OaAZuGxC1M=", "id"=>"4", "patient"=>{"occupation"=>"nothing", "blood_type"=>"O+", "next_of_kin"=>"mo man", "address"=>"arcklow", "m_name"=>"gfjhgjgfj", "date_of_first_admission(1i)"=>"2006", "tel_number"=>"45345435", "weight"=>"85.0", "date_of_first_admission(2i)"=>"3", "f_name"=>"Allan ", "date_of_first_admission(3i)"=>"3", "mobile_number"=>"43534543", "universal_ID"=>"bebo", "sex"=>"Female", "medical_history"=>"Wrist is", "height"=>"187.0", "family_history"=>"", "bmi"=>"15", "allergies"=>"", "date_of_birth(1i)"=>"1986", "date_of_birth(2i)"=>"8", "email"=>"allandx@gmail.com", "current_medication"=>"ibrufen", "date_of_birth(3i)"=>"17", "l_name"=>"Dixon"}}

WARNING: Can't mass-assign these protected attributes: occupation, blood_type, next_of_kin, address, m_name, date_of_first_admission(1i), tel_number, weight, date_of_first_admission(2i), f_name, date_of_first_admission(3i), mobile_number, universal_ID, sex, medical_history, height, family_history, bmi, allergies, date_of_birth(1i), date_of_birth(2i), email, current_medication, date_of_birth(3i), l_name


  [4;35;1mPatient Load (0.1ms)[0m   [0mSELECT "patients".id FROM "patients" WHERE ("patients"."email" = 'allandx@gmail.com' AND "patients".id  4) LIMIT 1[0m
  [4;36;1mPatient Load (0.1ms)[0m   [0;1mSELECT "patients".id FROM "patients" WHERE ("patients"."universal_ID" = 'bebo' AND "patients".id  4) LIMIT 1[0m
  [4;35;1mPatient Load (0.1ms)[0m   [0mSELECT "patients".id FROM "patients" WHERE ("patients"."l_name" = 'Dixon' AND "patients".date_of_birth = '1986-08-17' AND "patients".f_name = 'Allan ' AND "patients".tel_number = 45345435 AND "patients".id  4)

model code:

class Patient < ActiveRecord::Base

  #patient can have many apointments and vistis
  has_many :appointments, :dependent => :destroy
  has_many :visits, :dependent => :destroy

  # adding the photo as an attribute to patient 
  attr_accessible :photo
  has_attached_file :photo, :styles => { :small => "200x200>" }

  # validate  that fields are not blank
  validates_presence_of(:f_name, :l_name, :tel_number, :address)

  # validate that fields are numeric
  validates_numericality_of(:height, :weight, :bmi, :tel_number)

  #v alidate uniqueness of fields and users
  validates_uniqueness_of(:email, :universal_ID)
  validates_uniqueness_of(:l_name, :case_sensitve => false, :scope => [:date_of_birth, :f_name, :tel_number], :message => "User already existsts")

  #validate Email is right format
  validates_format_of(:email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :message => "Dosen't look like a real email address, please try again")

  #validate the date of birth
  validates_inclusion_of(:date_of_birth, :in => Date.civil(1900, 1, 1) .. Date.today, :message => "Must be between the year 1900 and today")


end

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:22:49+00:00Added an answer on May 16, 2026 at 3:22 pm
     # adding the photo as an attribute to patient 
     attr_accessible :photo
    

    Here is your problem maybe you wanted attr_accesor instead of attr_accesible ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sorry I didn't know how to title my question any better, you
Sorry for the vague title but I really didn't know what title to give
sorry, for the cryptic title i didn't find any better summary for my problem.
Sorry if this is a really basic question but it's been really getting to
Sorry for unclear subject but i really don't understand where problem. I use a
A really php newbie here, sorry if the question is too simple. I’m following
Really stupid question, sorry, but I can't find it on google (I'm sure it's
Sorry i really don't know how to code in PHP but i need to
Sorry for the confusing title, I didn't know how I could describe it better.
I didn't know if this should be posted here or on Programmers - Sorry.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.