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 9106577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:22:14+00:00 2026-06-17T02:22:14+00:00

I have a Rails application which handles hotel room reservations. I would like an

  • 0

I have a Rails application which handles hotel room reservations. I would like an admin to see all reservations and specific users to only see their reservations. Is the ‘proper’ way of doing this:

  1. Create a new action for each user in the reservation controller

    OR

  2. Put an if statement in the index action, deciding whether to return all reservations or only those for a user id sent by parameter

I have it set up and working the second way but I’m not sure this is the correct way of doing things.

  • 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-06-17T02:22:16+00:00Added an answer on June 17, 2026 at 2:22 am

    I would do this by having a single view, which is populated by the appropriate collection of reservations. For an admin this would be all reservations, but for a regular user the collection would only contain their bookings.

    This then requires a single if statement in the controller to ascertain the appropriate reservations:

    if user.is_admin?
      @reservations = Reservation.all
    else
      @reservations = user.reservations
    end
    

    The above code assumes that you’ve setup an appropriate relationship between a user and their reservations, but you get the idea.

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

Sidebar

Related Questions

I have Rails Application which uses JavaScript Extensively . I would like to know
I am writing ruby on rails application, which will have 2 different users types
I have a model in my rails application which is class Person < ActiveRecord::Base
I have a Rails 3.2.2 application which is a simple company intranet, however although
In my rails application, I have a controller called demo which is stored at
I have created a blog application using Ruby on Rails which includes the ability
I have a VPS which is hosting (currently) 5 different rails applications, all with
I'm creating a Rails application which uses MySQL. I have a table in my
I am experimenting with a design for a Rails application which will have most
I have a rails application which uses Device and Cancan for authentication. When I

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.