아래와 같은 방법으로 credentials.yml을 수정가능하다.

rails credentials:edit
EDITOR="code --wait" rails credentials:edit
# aws:
# access_key_id: 123
# secret_access_key: 345

위와 같은 코드를 볼 수 있는데, 주석을 지워주면

aws:
  access_key_id: 123
# secret_access_key: 345

위와 같은 형태로 되고, 저장을 하면

Rails.application.credentials.aws[:access_key_id]

로 접근이 가능하다. (콘솔에서 확인가능)

 

실제로 사용할때는 aws, access_key_id와 '123'을 수정해서 사용하면 된다.

master.key가 유출되지 않도록 조심

만약 master.key가 없다면 아래와 같은 오류가 뜨며 credentials에 접근이 불가능하다.

Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?

'ruby on rails' 카테고리의 다른 글

AJAX in ruby on rails  (0) 2020.11.20
manage exception  (0) 2020.11.20
setup and use api-key to get stock data  (0) 2020.11.19
devise: configuring view  (0) 2020.11.19
add devise gem for authentication  (0) 2020.11.19

iexcloud.io 가입 후 제공되는 API Tokens를 이용,

gem 'iex-ruby-client'
client = IEX::Api::Client.new(
  publishable_token: 'publishable_token',
  secret_token: 'secret_token',
  endpoint: 'https://sandbox.iexapis.com/v1'
)

console에서 다음으로 테스트

client.price('AAPL')

 

참고: github.com/dblock/iex-ruby-client

 

dblock/iex-ruby-client

IEX Finance API Ruby Client. Contribute to dblock/iex-ruby-client development by creating an account on GitHub.

github.com

 

'ruby on rails' 카테고리의 다른 글

manage exception  (0) 2020.11.20
secure credentials  (0) 2020.11.20
devise: configuring view  (0) 2020.11.19
add devise gem for authentication  (0) 2020.11.19
websocket via ActionCable  (0) 2020.11.18

devise의 view를 수정하기 위해서 다음 명령어를 console에 입력시켜주면 view가 생성된다.

rails generate devise:views

 

나는 bootstrap template를 이용할 것이므로 다음 코드를 gemfile에 추가시켜 주고, gem 설치를 해준다.

gem 'devise-bootstrap-views', '~> 1.0'
bundle install --without production

그리고 다음 명령어를 console에 입력해주면 view가 생성된다.

rails generate devise:views:bootstrap_templates

참고: github.com/hisea/devise-bootstrap-views

 

hisea/devise-bootstrap-views

Contribute to hisea/devise-bootstrap-views development by creating an account on GitHub.

github.com

 

'ruby on rails' 카테고리의 다른 글

secure credentials  (0) 2020.11.20
setup and use api-key to get stock data  (0) 2020.11.19
add devise gem for authentication  (0) 2020.11.19
websocket via ActionCable  (0) 2020.11.18
view refactoring  (0) 2020.11.18

1. sign up - hashed password, confirmation(email), forgot password, remember user

2. login

3. log out

 

gemfile에 추가

gem 'devise'

devise 설치하고 User model 생성, migrate

bundle install --without production
rails generate devise:install
rails generate devise User
rails db:migrate

controller에 before_action 추가

before_action :authenticate_user!

참고: github.com/heartcombo/devise#starting-with-rails

 

heartcombo/devise

Flexible authentication solution for Rails with Warden. - heartcombo/devise

github.com

 

'ruby on rails' 카테고리의 다른 글

setup and use api-key to get stock data  (0) 2020.11.19
devise: configuring view  (0) 2020.11.19
websocket via ActionCable  (0) 2020.11.18
view refactoring  (0) 2020.11.18
favicon  (0) 2020.11.18

ActionCable setup하기

rails generate channel chatroom
      create  app/channels/chatroom_channel.rb
   identical  app/assets/javascripts/cable.js
      create  app/assets/javascripts/channels/chatroom.coffee

위와 같이 두 파일이 생성된다

chatroom_channel.rb에서

def subscribed
  stream_from "chatroom_channel"
end

와 같이 스트림을 열어주고

routes.rb에서

mount ActionCable.server, at: '/cable'

ActionCable server를 마운트해준다

'ruby on rails' 카테고리의 다른 글

devise: configuring view  (0) 2020.11.19
add devise gem for authentication  (0) 2020.11.19
view refactoring  (0) 2020.11.18
favicon  (0) 2020.11.18
console db 시각화  (0) 2020.11.17

+ Recent posts