0

I am building a team management app in Rails where :users has many :organizations. I would like for users to be able to switch between organisations and manage them individually without having the /organizations/:id/ in the URL. Due to Wildcard SSL certificate costs, I would also like to avoid using subdomains to identify the organization.

As I understand it, this leaves two options:

  1. Store the current organization in the DB.
  2. Store the current organization in the session.

What would be the best option here?

Thanks

1
  • 1
    If you're just not wanting the id in the URL, you can use something like FriendlyId to create slugs for each organization, which can be as random as you'd like. Commented Feb 27, 2017 at 3:25

1 Answer 1

2

Simply store it in the session, there's no reason to do it any other way. I would also create a before_action in the application controller to automatically load the organization into an instance variable available to your controllers and views.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.