Posts

Showing posts from January, 2022

api

  Mobile Rails API with Devise 1.  Add column in User table    rails g migration AddAuthenticationtokenToUsers authentication_token:string 2.  rails generate controller Api/V1/Api 3.  User.rb      before_save :ensure_authentication_token    def ensure_authentication_token     if authentication_token.blank?       self.authentication_token = generate_authentication_token     end   end   private   def generate_authentication_token   loop do     token = Devise.friendly_token     break token unless User.find_by(authentication_token: token)   end   end 4.   ApiController   class Api::V1::ApiController < ApplicationController   def create   end   def destroy   end   respond_to :json helper_method :current_user def getting_started end def current_user   @current_user ||= User.wher...