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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:02:37+00:00 2026-05-25T22:02:37+00:00

I have three different models that will be involved with this. I am trying

  • 0

I have three different models that will be involved with this. I am trying to create a user who will belong to an owner. The owner has many partners and the partner has many clients. The problem with this and how it varies from other questions asked here, is that I do not want someone to view source of the page and see the entire list of clients. This is currently in devel/testing phase right now. I will eventually restrict the owner_id to be hard coded to the @current_user’s owner_id. This owner user can only see their own partners and those partner’s clients. I would not want them to see the partners of another owner.

<%= f.input :owner_id, :as => :select, :collection => Owner.find(:all) %>
<%= f.input :partner_id, :as => :select, :collection => Partner.find(params[:owner_id]) %>
<%= f.input :client_id, :as => :select, :collection => Client.find(params[:partner_id]) %>

The issue that I have above is that the find params is generating an error since the :owner_id has no value and is not going to find any partners. So how do I go about having the client selection populate the list of clients when a partner is selected. Likewise, how to figure out how to populate the Partners once the owner is selected. Keep in mind, that the owner line will change once I figure this piece out. There’s no point in moving forward until this is figured out.

If this were a City based on the State chosen, I’ve found several options but haven’t found the right one with this yet. Thanks guys!

  • 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-25T22:02:37+00:00Added an answer on May 25, 2026 at 10:02 pm

    I don’t think you’re understanding (or taking advantage of) the model associations. Since I don’t fully understand your model or business domain, I’m doing a lot of hand-waving here… it sounds like you want to restrict the number of options in the select box to just those that the current user should be able to see.

    Let’s say you had a Tumblr-style app. You have many users, and many blogs. The current logged in user can post a new item to any one of the blogs they have access to. When creating a new post and selecting which blog to publish it in, it would not be appropriate to let me post to your blog, or even know it exists. Instead of Blog.all, we’d use @current_user.blogs.

    <%= semantic_form_for @post do |f| %>
      <%= f.input :blog, :label => "Which blog?", :as => :select, :collection => @current_user.blogs %>
      ...
    <% end %>
    

    I would see my list of blogs to choose from, you’d see yours. I think this partially answers your question.

    The other part of the question seems to be around dynamically altering the contents of the select box based on the selections made in other select boxes in the form. This is something that would need to be handled with Javascript/AJAX, and kind of out-of-scope for Formtastic and a simple answer on Stack Overflow 🙂

    I’d recommend keeping this as simple as possible for a first version.

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

Sidebar

Related Questions

I'm completely stumped on this one. I have three different lists that need to
I have a table that has three different date columns, so I set each
I have an existing site that has a bunch of different models and controllers.
I'm playing with a GWT/GAE project which will have three different pages, although it
I have a function that receives three different people objects and generates a new
I have an Android project that branched into three different applications, app-1 , app-2
I have the following three models: User, Project, and Assignment. A User has_many Projects
I have been trying different techniques while designing this application, which to me is
I have three different configurations on my project, all three do not require all
I have three different development machines. Do I need three different iPhone Developer Program

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.