This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#to create user | |
@user = User.new | |
@user.email = 'xyz@gmail.com' | |
@user.password = 'test123' | |
@user.save | |
#to set admin role | |
@user.add_role :admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#prototype of how an action which returns JSON should look. | |
def action | |
@result = Hash.new | |
@result['status'] = true | |
@result['error_messages'] = [ ] | |
@result['success_messages'] = [ ] | |
if <success> | |
@clients = Client.all | |
@clients_data = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def additemtoorder | |
@result = Hash.new | |
@result['status'] = true | |
@result['error_messages'] = [] | |
@result['success_messages'] = [] | |
@order = Order.find(params[:id]) | |
@product = Product.find(params[:productid]) | |
@skus = ProductSku.where(:product_id=>@product.id).where(:purpose=>'primary') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_user | |
@result = Hash.new | |
@result['status'] = true | |
@result['error_messages'] = [ ] | |
@result['success_messages'] = [ ] | |
if params[:password] == params[:password_confirmation] | |
@user = User.new | |
@user.fist_name = params[:first_name] | |
@user.last_name = params[:last_name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if params[:change_password] | |
if params[:password].nil? && !params[:password_confirmation].nil? && params[:password] == params[:password_confirmation] | |
@user.password = params[:password] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@user = User.new | |
@user.user_name = params[:user_name] | |
@user.first_name = params[:first_name] | |
@user.last_name = params[:last_name] | |
@user.email = params[:email] | |
@user.password = params[:password] | |
@user.password_confirmation = params[:password_confirmation] | |
@client.user = @user | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$http.get('/users_admin/list_users.json').success(function(data) { | |
if(data.status == true) { | |
$scope.users_list = data.users; | |
} | |
else { | |
$scope.error_messages = data.error_messages; | |
// add flag to show error messages in the view. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"example":"this is test"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.reset_messages(); | |
$http.post('url').success(function(data){ | |
$scope.status = data.status; | |
if (data.status) { | |
$scope.success_messages = data.success_messages; | |
} | |
else { | |
$scope.error_messages = data.error_messages; | |
} | |
}).error(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.reset_messages = function() { | |
$scope.error_messages = []; | |
$scope.success_messages = []; | |
$scope.show_success_message = false; | |
$scope.status = null; | |
} |
OlderNewer