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

  • Home
  • SEARCH
  • 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 5978221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:28:58+00:00 2026-05-22T21:28:58+00:00

Hey all! Just joined up on stack overflow, as it has been a helpful

  • 0

Hey all! Just joined up on stack overflow, as it has been a helpful resource while starting to learn about Ruby on Rails 3.

I can’t seem to find one particular answer though, and maybe I’m barking up the wrong tree for all I know, but hopefully you folks can sort me out here. First some info on what I’m working with:
– In my web app I have 2 models: Projects and Tasks in a one-to-many relationship.
– Projects has many Tasks, and Tasks belong to Project
– Tasks IS NOT a nested resource, as users need to be able to see all current tasks, regardless of which project they are for.
– routes.rb therefore looks like this right now:

resources :projects
resources :tasks

In the project show view I display a list of tasks associated with that project. below that there is a link_to for creating a new task that looks like <%= link_to ‘New Task’, new_task_path, :class => “new-btn” %>. The link_to takes user to the new view for creating a new task. The rendered _form view starts with: <%= form_for(@task) do |f| %>.

Now, I think I need to pass the project id from the project show view, to the new task view: but, this is where I am getting lost and possibly, a bit mixed up.

Could someone please point me in the right direction: maybe to a resource outlining all steps involved in doing this, or maybe even provide an outline of the steps involved in the process here.

Many thanks!

  • 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-22T21:28:59+00:00Added an answer on May 22, 2026 at 9:28 pm

    If current_user returns User object then you should be able to call

    current_user.projects 
    

    to get all user’s projects.

    Defining a relation between user and task may be working (though I am not sure this one).

    #models/user.rb
    has_many :projects
    has_many :tasks, :through => :projects
    

    In this case simply

    current_user.tasks 
    

    should return user’s tasks

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

Sidebar

Related Questions

Hey all I've just been fooling around with the HTML5 Database API and I'm
Hey all, I'm just starting with Grails in Netbeans (6.9.1). I got a demo
Hey all, I know this question has been asked a million times before but
Hey, I just began to learn ruby/rails. At the moment, I try to do
Hey all, I'm just wondering if it is possible to get the name of
Hey all, basically i have an empty AS3 fla file with just the following
Hey guys, I am just trying to pull all the records from my database
Hey, I need to delete all images from a string and I just can't
hey all, just getting started on hadoop and curious what the best way in
hey all, I'm just getting started with c3p0 for database connection pooling. It's attaching

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.