Stephen Sizer

Joined

3,780 Experience
16 Lessons Completed
1 Question Solved

Activity

Whats the best way to tackle cron jobs on Heroku as the whenever gem isn't supported?

Posted in Nested has many through... Or is there a better way?

Hi I have 2 models Tender and Group shown below.

For a Tender you can add Contractors (contractor_details) and you can also add Groups (groups). Groups also contain contractor_details.

This is so that they may want to categorize certain contractors they use alot into specific groups by speciality e.g. Joiners, Electrians e.t.c..

What would the best way for me to check all contractors added to a tender including through groups, this is so that I can then do authorization and only allow those contractors added to view the tender page?

class Group < ApplicationRecord
  belongs_to :company_detail
  has_many :group_contractors, dependent: :destroy
  has_many :contractor_details, through: :group_contractors
  has_many :tender_groups
  has_many :tenders, through: :tender_groups

  accepts_nested_attributes_for :group_contractors

  validates :name, presence: true
end
class Tender < ApplicationRecord
  belongs_to :user
  belongs_to :company_detail
  has_many :questions
  has_many :assets
  has_many :tender_groups, dependent: :destroy
  has_many :groups, through: :tender_groups
  has_many :tender_contractors, dependent: :destroy
  has_many :contractor_details, through: :tender_contractors
  has_many :bids

  accepts_nested_attributes_for :tender_groups
  accepts_nested_attributes_for :tender_contractors
  accepts_nested_attributes_for :assets

  validates :title, :length_days, :summary, presence: true  

end

Hi,
I've got a system where users upload documents with expiry dates. I want to send the user an email reminder 1 month and 1 week before expiration to remind them to upload a new document.

What's the best way to do this?

Thanks in advance.
Steve

Posted in Multiple Devise Users sharing a dashboard

Thanks for the super speedy response :)

Posted in Multiple Devise Users sharing a dashboard

Hi,

I have currently two Devise models Company and Contractor.

When they sign in I want to redirect them to a dashboard page. At the moment I have a before_action on the dashboard controller that only allows authenticate_company! so when a contractor signs in they can't view the dashboard.

Anyone done something like this before? Also is there an easy way to check which user is currently logged in so that I can show them different partial views?

Thanks in advance