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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:24:42+00:00 2026-06-04T12:24:42+00:00

I’m working with three models: user, project, and userprivilege. The userprivilege model consists of

  • 0

I’m working with three models: user, project, and userprivilege. The userprivilege model consists of a user_id, a project_id, and an accessLevel value. The user and project models have a ‘has_many’ relationship with userprivilege, and a ‘has_many, through’ relationship with each other.

When a user creates a project, a corresponding entry is created in the userprivileges table. I’m not sure how to create such an entry for a situation where a user shares a project with another user. In this situation, a user visits a project page, clicks on a link to share access to the project, and specifies the e-mail of the target user.

I’m associating this situation with the ‘new’ action in the UserprivilegesController. In the ‘create’ action, I can access the user object with whom the project is being shared (using the email id), but I’m not sure how to get the project id of the project being shared. Is there a way to store the project id when the user visits the project page and clicks on the share access link?

Thanks.


I was able to solve this issue thanks to Aldo’s comment. But, I have a related question: Is it possible to approach this using the routes.rb file. Could I include the routes for the Userprivilege actions in the Project routes? As examples, something like: /projects/1/userprivileges/new or /projects/1/userprivileges/1/edit. Then, I could get the project id from the URI. But, a restriction would be necessary such that userprivileges can only be accessed from the projects to which they relate, so something like /projects/2/userprivileges/1/edit wouldn’t be allowed. How could I implement that restriction?

  • 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-04T12:24:43+00:00Added an answer on June 4, 2026 at 12:24 pm

    You should pass the project_id to UserprivilegesController#new. Use the link_to options to do this in your project view, for example:

    # app/views/project.html.erb
    <%= link_to "Share access", {controller: 'userprivileges', action: 'new', project_id: @project.id}
    

    Then once in that controller you get this value from the parameters using params[:project_id] and add somewhere in your form using an hidden field (using hidden_field or hidden_field_tag depending on the way your’re building your form).

    The idea is to pass the project_id when the user submit the form so that the UserprivilegesController#create action can access it using (again params[:project_id]).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but

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.