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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:58:21+00:00 2026-06-06T11:58:21+00:00

I am using Rails 3, and building an app in which a user can

  • 0

I am using Rails 3, and building an app in which a user can put objects to be rented. For each object, he can decide:

  • the object can be rented by the entire world (potentially) or not (object access is restricted)
  • the object can only be rented by my friends (in the app, via a has_many friends, :through => friendship association)
  • the object can be rented by members of the following groups (then the user selects either all the groups he belongs to, or a subset of these)

My question is how to display the list of objects a current_user can see ? I see two options, and I would like to know which is the best one or if they are equivalent:

1) In the object controller, build the collection of the objects a user can see (@objects = Object.can_see(current_user)) and then pass this to the index view and display the whole list

2) In the controller, collect ALL objects (@objects = Object.all), pass this to the index view, and in the view, for each object, conduct a serie of test to determine if the object should be displayed or not.

  • 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-06T11:58:23+00:00Added an answer on June 6, 2026 at 11:58 am

    In the end, it is really up to you to decide based on where you see the project headed. You really have three options though:

    1. Handle the entire query via SQL statements.
    2. Handle some of the initial filtering via SQL statements, then filter the returned data.
    3. Return all of the data via SQL statements, and filter the returned data.

    Keep in mind that SQL db’s are built for performing fast data access. I would be very surprised if your solution didn’t have any initial filtering, unless you were returning very small data sets to filter. In the end, it comes down to how complex your logic is (can it be expressed in SQL and still understood?), how performant each option would be, and how scalable the solution would be.

    There are also a number of good ORM’s out there that can help blur the line between your business logic and data access. Many of them will dynamically create the complex SQL based on your code, so there isn’t as much of a concern about how ugly it’ll be.

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

Sidebar

Related Questions

I am in the early stages of building an app using Rails 3. User
I am building a Rails application which allows a user to create an object
I'm building an app in Rails 3. I currently have a user model which
I'm currently building a Rails app, where a user can upload an mp3 and
I am building my first Ruby on Rails app which is going to be
I am building a Rails 3 app which renders different views for mobile devices
We're building an app, our first using Rails 3, and we're having to build
I'm building an app in Rails 3 using Authlogic for authentication. I have a
I am building an app using Rails 3 that allows users to submit videos.
I am building a rails app using the wonderful activemerchant gem to save credit

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.