Aniket Rao

Joined

990 Experience
1 Lesson Completed
1 Question Solved

Activity

Posted in Deploy Ubuntu 18.04 Bionic Beaver Discussion

Hey, did you fix it?

Posted in Multi tenant best strategy

Here is the thing, even if you privatize the User model you still have a global user. Which you can access by just giving the route correctly and scoping it by /admin under a No Subdomain Constraint.

By doing so you can have users in Private exclusive to the respective tenants/accounts and users in Global. In my case I use these users as Account/Tenant Admins.

If at all this helps! If you need a video demo for better understanding then I'm willing to schedule a time so we can screenshare and I can show you around.

Cheers!

Posted in Rails API backend with Electron Frontend

Hey so here is what I referred to to build or rather to understand how to build https://scotch.io/tutorials/build-a-music-player-with-react-electron-i-setup-basic-concepts

There also some material on Lynda https://www.lynda.com/Electron-tutorials/Electron-Building-Cross-Platform-Desktop-Apps/518051-2.html

Unfortunately there is not much to refer to than these. I could explain, but I am super swamped at work clocking about 14-15 sometimes 16 hours. Startup mode :|

Cheers!

Posted in Rails API backend with Electron Frontend

I think its a very viable proposition. Infact I recommend to go with it. I created one for a client. Same SaaS platform API, React Frontend, ReactNative Mobile App and a Electron Desktop App. If you are familiar with React/Redux then you can implement that in Electron as well. I also went ahead with some offline capabilities by using Postgres as a local DB. Checkout https://github.com/brianc/node-postgres .

I cannot stress on how affordable it is to build one. Its just Javascript end of day and moreover if you have worked with React enough this shouldn't be difficult at all.

Go ahead! Give it a shot!

Cheers!

Posted in Multi tenant best strategy

Yes you would need to exclude users and scope it independently to the account it was created. I could explain more but I guess this video on youtube might give you better clarity on how to approach.

https://www.youtube.com/playlist?list=PLY_TsbWXHC0IaIWdnQwkLRdg9pXsyY_pW

Let me know if you have any questions. Be glad to help. I have been working on this Multitenant Architecture for over a year now and still on it.

If you are on GoRails Slack then you can reach me at @aniketrao

Cheers!

So I have a Multitenant SaaS Application where users signup, pay, create an account and start using the service. Now I have received a requirement where this service needs to have a andriod client which needs to be global to the application and not the tenant. Now how do I make my SaaS application to act as a OAuth2 provider and authenticate and authorize the client?

If the user wants to sign in via the Android Client, at that moment I do not know which tenant/account the user belongs to so I cannot confirm the subdomain in play for confirmation.

Can anybody suggest a good way to handle this?

Posted in How to I Architect my application?

So I have been tasked with a project where I have 3 entities, say a retail shop, wholesale shop and a manufacturer. Each have their own schemas (each shop has its own subdomain). All three entities have requested for their own database but they want frequent transactions happening between the shop, wholesaler and manufacturer.

I have been thinking about this for a while but could not think of a good viable approach. What would be the right approach to execute?

Here is the Schema for Uploads


create_table "uploads", force: :cascade do |t|
    t.string   "file"
    t.string   "file_id"
    t.string   "file_filename"
    t.integer  "file_size"
    t.string   "file_content_type"
    t.integer  "uploadable_id"
    t.string   "uploadable_type"
    t.datetime "created_at",        null: false
    t.datetime "updated_at",        null: false
  end

  add_index "uploads", ["uploadable_id", "uploadable_type"], name: "index_uploads_on_uploadable_id_and_uploadable_type"

Below are the model files

# app/models/upload.rb

class Upload < ActiveRecord::Base
  belongs_to :uploadable, polymorphic: true
  attachment :file

## Not working hence commented out
  # after_destroy :remove_file

  # private

  #   def remove_file
  #     file.delete
  #   end

end
# app/models/product.rb
class Product < ActiveRecord::Base
 has_many :uploads, as: :uploadable, dependent: :destroy
 accepts_attachments_for :uploads, attachment: :file, append: true

end
# app/models/spare.rb
class Spare < ActiveRecord::Base
 has_many :uploads, as: :uploadable, dependent: :destroy
 accepts_attachments_for :uploads, attachment: :file, append: true

end
# app/models/item.rb
class Item < ActiveRecord::Base
 has_many :uploads, as: :uploadable, dependent: :destroy
 accepts_attachments_for :uploads, attachment: :file, append: true

end
# app/controllers/products_controller.rb
class ProductsController < ApplicationController

  before_action :set_product, only: [:show, :edit, :update, :destroy]
  before_filter :permission_check, only: [:show, :edit, :update, :destroy]
.
.
.
.
.

private
.
.
  def product_params
    params.require(:product).permit( :product_name, ...., uploads_files: [] )
  end

end

Spares and Items also have exact same

params.require(:product).permit(uploads_files: [])

Followed as per gem documentation and got uploads working. But for weeks I have been struggling on getting the delete function working. hoping if you can give it shot and share your insight.

Thanks mate!

Cheers