From b8a4c268cea5a0354a8f0f19bc6e3f10165da1dd Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Wed, 24 Sep 2014 22:52:12 +0900 Subject: [PATCH] Enable download of user credentials. Closes #529. --- app/controllers/user_credentials_controller.rb | 4 +++- app/views/user_credentials/index.html.erb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/user_credentials_controller.rb b/app/controllers/user_credentials_controller.rb index d988f257..e9228a33 100644 --- a/app/controllers/user_credentials_controller.rb +++ b/app/controllers/user_credentials_controller.rb @@ -8,7 +8,9 @@ class UserCredentialsController < ApplicationController respond_to do |format| format.html - format.json { render json: @user_credentials } + format.json { + send_data Utils.pretty_jsonify(@user_credentials.limit(nil).as_json), disposition: 'attachment' + } end end diff --git a/app/views/user_credentials/index.html.erb b/app/views/user_credentials/index.html.erb index 6f347db4..71d7b06b 100644 --- a/app/views/user_credentials/index.html.erb +++ b/app/views/user_credentials/index.html.erb @@ -37,8 +37,9 @@
- <%= link_to ' New Credential'.html_safe, new_user_credential_path, class: "btn btn-default" %> + <%= link_to new_user_credential_path, class: "btn btn-default" do %> New Credential<% end %> + <%= link_to user_credentials_path(format: :json), class: "btn btn-default" do %> Download Credentials<% end %>
- \ No newline at end of file +