Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:09:29+00:00 2026-05-30T04:09:29+00:00

Building a rails B2B application that will have various users. I’m pretty clear on

  • 0

Building a rails B2B application that will have various users. I’m pretty clear on restricting access for internal staff using Devise and CanCan but I want to be able to give suppliers and customers their own login as well. Customer will be fairly simple, however, I want to ensure the supplier (label) login enables them to view and amend their own product and sales data only.

The model is roughly:

User (as setup by Devise)
Label [has_many releases]
Release [belongs_to label / has_many products]
Product [belongs_release / has_many tracks]
Track [belongs_product]

I’m guessing I could add in a label_id field on the user model and associate that way but I need internal users (and customers) to have access to view all label data. I also need to allow a label to have many users.

Would it simply be a case of defining a ‘label’ role via Cancan that enforces the use of a label_id in the the views? If that’s the correct approach how do I then lock down the content to that label_id in my controllers/views? Role based if statements?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:09:30+00:00Added an answer on May 30, 2026 at 4:09 am

    What you’d first have to do is define some CanCan roles, like supplier, customer and staff, and then create an interstitial controller to handle the forking:

    class CheckingController < ApplicationController
      def index
        @path = case user.role
          when 'supplier'
            supplier_path
          when 'customer'
            customer_path
          when 'staff'
            staff_path
          else
            admin_sign_in_path #or whatever
        end
    
        redirect_to @path     
      end
    end
    

    Then in your routes.rb file you can send users to either the root or index action of your controller by first sending them to CheckingController#index which will redirect based on your CanCan roles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at building a Rails application which will have some pretty large tables
I'm building a Rails 3 application that will have user-specific settings (looks, functionality, etc)
I am building a Rails app that will allow users to publish their location
I have been building a Rails application that performs accounting functionality. As part of
I'm building a Rails application that requires some models to interact with some necessary
I'm building a Rails site that, among other things, allows users to build their
I'm building Rails application and I want to have user registration/login functionality. I also
I am currently building a Rails 3.2 application that uses the gem sunspot to
I have a SharePoint server. I am building an rails application which can interact
I'm building a Rails application that deals with file uploads through CarrierWave. Currently, larger

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.