Permalink
Browse files

fixing user forms

  • Loading branch information...
1 parent fab8d64 commit 5e889c0e9d1918ea389bf0fddf1189016995eb18 Dimitri Kurashvili committed May 30, 2012
Showing with 11 additions and 2 deletions.
  1. +10 −2 app/controllers/users_controller.rb
  2. +1 −0 app/models/user.rb
@@ -21,12 +21,20 @@ def edit
def create
@user = User.new(params[:user])
- redirect_to(@user, :notice => 'მომხმარებელი შექმნილია.') if @user.save
+ if @user.save
+ redirect_to(@user, :notice => 'მომხმარებელი შექმნილია.')
+ else
+ render :new
+ end
end
def update
@user = User.find(params[:id])
- redirect_to(@user, :notice => 'მომხმარებელი განახლებულია.') if @user.update_attributes(params[:user])
+ if @user.update_attributes(params[:user])
+ redirect_to(@user, :notice => 'მომხმარებელი განახლებულია.')
+ else
+ render :edit
+ end
end
def destroy
View
@@ -6,6 +6,7 @@ class User < ActiveRecord::Base
attr_accessor :password_confirmation
validates_confirmation_of :password
+ validates_presence_of :name, :first_name, :last_name, :phone
validate :password_non_blank

0 comments on commit 5e889c0

Please sign in to comment.