I'm new to Ruby/RoR and so far things have been going well, but I am having issues with updating the database from a form field (every field saves except the birthday field). I assume there is a minor implementation issue here but I'm having trouble working it out.
Form:
<%= f.label :birthday %>
<%= f.date_select :birthday, {order: [:month, :day, :year], prompt: { day: 'Select day', month: 'Select month', year: 'Select year' }, start_year: Date.today.year - 118, end_year: Date.today.year}, class: 'form-control' %>
User model:
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
flash[:success] = "Profile updated"
redirect_to @user
else
render 'edit'
end
end
def user_params
unless logged_in?
params.require(:user).permit(:first_name, :last_name, :email, :usertype, :password,:password_confirmation)
else
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :street, :city, :state, :zipcode, :phone_number, :birthday, :month, :day, :year)
end
end
Database migration for field
add_column :users, :birthday, :date
add_column :users, :month, :date
add_column :users, :day, :date
add_column :users, :year, :date