orbit-basic/app/controllers/basic_infos_controller.rb

54 lines
1.1 KiB
Ruby

class BasicInfosController < ApplicationController
layout "devise"
def index
if params[:user_id].nil?
redirect_to "/users/sign_up"
end
@user = User.find(params[:user_id])
end
def form_page
@user = User.find(params[:user_id])
end
def basic_info_update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to basic_infos_role_page_path(:user_id => @user.id.to_s)
else
render :action=> "form_page"
end
end
def role_page
@roles = Role.where(:disabled => false)
@user_id = params[:user_id]
end
def role_update
user = User.find(params[:id])
if user.update_attributes(params[:user])
redirect_to "/users/sign_in"
else
@roles = Role.where(:disabled => false)
render :action => "role_page"
end
end
def check_availability
response = {}
case params[:type]
when "user_id"
response["success"] = User.where(:user_id => params[:value]).count > 0 ? false : true
when "user_email"
response["success"] = User.where(:email => params[:value]).count > 0? false : true
end
render :json => response.to_json
end
end