orbit-basic/app/controllers/basic_infos_controller.rb

54 lines
1.1 KiB
Ruby
Raw Normal View History

2013-11-25 12:24:56 +00:00
class BasicInfosController < ApplicationController
layout "devise"
def index
2013-11-29 10:46:07 +00:00
if params[:user_id].nil?
2013-11-26 11:14:24 +00:00
redirect_to "/users/sign_up"
end
2013-11-29 10:46:07 +00:00
@user = User.find(params[:user_id])
2013-11-25 12:24:56 +00:00
end
def form_page
2013-11-26 11:14:24 +00:00
@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"
2013-11-26 11:14:24 +00:00
else
@roles = Role.where(:disabled => false)
render :action => "role_page"
end
2013-11-25 12:24:56 +00:00
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
2013-11-25 12:24:56 +00:00
end