Tabish Iqbal

Joined

6,000 Experience
17 Lessons Completed
5 Questions Solved

Activity

Posted in Realtime Nested Comments: Part 3 Discussion

How does this work with someones avatar thats uploaded using activestorage? I get the following url for the image

http://example.org/rails/active_storage/representations/redirect/...../chewy.jpeg

where the example.org was set in application_controller_renderer.rb. Even after replacing it to "localhost" it still doesn't work. When you do a full page reload all the avatars show up.

Posted in Realtime Nested Comments: Part 2 Discussion

Not going to lie I hear some beeping sound or popping sound and then raise my right or left arm depending on which ear I heard it in. Am I the only one hearing this or what? It's low key making me do the hearing test...

Posted in How to use Hotwire in Rails Discussion

do you have a /assets/javascripts/libraries folder? installed it for asset pipeline or webpack?

Posted in How to use Hotwire in Rails Discussion

prob the best xmas gift he got...

Howdy. You can have your static marketing pages in the same app if you like. The way I have done it is have routing constraints. IE

class MarketingSite
  def self.matches?(request)
    request.subdomain.blank? || request.subdomain == "www"
  end
end

class App
  def self.matches?(request)
    request.subdomain.present? && request.subdomain == "app"
  end
end

Rails.application.routes.draw do
  constraints(MarketingSite) do
    root "static#index"
    get "/pricing", to: "static#pricing"
    get "/contact", to: "static#contact"
  end

  constraints(App) do
    ....routes...
  end
end

And then you will have a views/layouts/static.html.erb which will be used by the static controller like so:

class StaticController < ApplicationController
  layout "static"
end

Posted in Row-level Multitenancy with ActsAsTenant Discussion

You can let people sign up using devise but accept a nested attribute for company and get the company name on the signup form as well. Company has many users and user belongs to company. Another thing is having a join table so

Company: has_many company_users
CompanyUser: belongs_to company, belongs_to user
User: has_many :company_users, belongs_to company, through: company_user

Posted in Row-level Multitenancy with ActsAsTenant Discussion

If it's not a healthcare app or where it's required that data needs to be separated then row based.

Posted in Trouble with a lending library query

No problem! Yea the states I had were much more and I ended up using the gem but your stuff works so glad I could help!

Posted in Trouble with a lending library query

Hey Peter! What you want to do is have a state/status column on your Book. This way the initial state is 'Available' and then when a check-out record is created that state/status on the book can be changed to "Checked-out". When someone is returning that book and you update the 'checked_in_at' datetime column you can update the status of the book back to Available.

This way you don't have to do weird queries but can just query for all books that are 'Available" or "Checked-out"

With AASM I was able to do something like this:

aasm column: :status do
    state :available, :initial => true
    state :checked_out

   event :checkout do
      transitions :from => :available, :to => :checked_out
    end

    event :checkin do
      transitions from: :checked_out, to: :available
    end

end

On book's you would just have an aasm column or a status column which is of string type.

Posted in How to use Uppy with ActiveStorage Discussion

Masud - Currently working on this with Ahad using Shrine + Stimulus

Posted in Uppy Video

Share your code. Give some background - using active storage etc.

Was having issues with this but found out behavior was changed from Rails 5. You have to now add the following in your application.rb file:

  config.active_storage.replace_on_assign_to_many = false

Notes on this can be found in the change logs here: https://edgeguides.rubyonrails.org/6_0_release_notes.html#active-storage-notable-changes

Posted in Which native app technology to pair with Rails

I would go with flutter as it does native unless you already know js and can go ionic etc

Best is to have a wrapper around your your app. Chris talks about this too but just as a refresher

<body>
  <div class="wrapper" data-behavior="vue">
    <%= yield %>
  </div>
</body>

Then throughout your app on your html.erb files you can insert vue components like so
show.html.erb

<div>
  <vue-component
    :posts="<%= @posts.to_json %>"
  ></vue-component
</div>

This will then display your vue component on that page. Alternatively you can also do things like this:

Have a vue component say SomeForm.vue where you will not have a template as you'll take advantage of the in-line template feature of Vue. You can import whatever library you want in that vue component have your data, methods etc setup and then do something like this in your html.erb file:

<some-form inline-template :post="<%= @post.to_json %>" >
  <div>
    <div >
      <label class="form-control-label">Post</label>
    </div>
    <treeselect 
        :options="posts" 
        v-model="selectedParent" 
        :placeholder="placeholderText"
        :normalizer="normalizer"
        :show-count="true"
        value-format="object"
    ></treeselect>
    <%= form.hidden_field :parent_id, {"v-model": "value"} %>
  </div>

   <div>
       <%= form.label :barcode, class: "form-control-label" %>
     <%= form.text_field :barcode, class: "form-control", placeholder: "0027081", "v-on:blur": "isUniqueBarcode", "v-model": "item.barcode", ":class": "{'border border-red': validationErrors.uniqueBarcode}" %>
     <span class="text-red" v-if="validationErrors.uniqueBarcode">Barcode already exists</span>
  </div>
</some-form>

how are you installing node? iwould recommend using nvm and prob best to let us know the steps you took

Posted in How to use Uppy with ActiveStorage Discussion

Thanks for this!

Posted in Looking for VERY Basic Rails EXPLANATION videos

I think it would be better if you ask questions about what you don't understand.

"stuck on the basics and understanding the “need” and/or implementation of certain things."

What things do you understand or don't? and if you just want someone to break it down from the beginning.

Posted in Multitenancy with the Apartment gem Discussion

You can do something like this. In application_controller.rb

set_current_tenant_through_filter
before_action :set_tenant

def set_tenant
   account_id = user_signed_in? ? current_user.account_id : false
   set_current_tenant(account_id)
end
logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.