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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:16:16+00:00 2026-06-12T01:16:16+00:00

I want a user to be able to create a challenge (challenges_created) and other

  • 0

I want a user to be able to create a challenge (challenges_created) and other users to be able to offer support to achieve them (challenges_supported). I tried to do this with a self joined challenge model with its resources nested beneath the users resource. I currently have models:

class User < ActiveRecord::Base
  attr_accessible :name, :supporter_id, :challenger_id

  has_many :challenges_created, :class_name => 'Challenge', :foreign_key => :challenger_id
  has_many :challenges_supported, :class_name => 'Challenge', :foreign_key => :supporter_id
end

and

class Challenge < ActiveRecord::Base
  attr_accessible :challenger, :completion_date, :description, :duration, :status,      :supporter, :title

  belongs_to :challenger, :class_name => 'User'
  has_many :supporters, :class_name => 'User'
end

I think that I would need full CRUD and corresponding views both for when users are creating challenges and when they are supporting them. Because of this, I created 2 controllers named challenges_created_controller and challenges_supported_controller.

My routes.rb file is:

resources :users do
  resources :challenges_created
  resources :challenges_supported
end

The problem that I am encountering with this setup is that when I try to create a new challenge at

http://localhost:3000/users/3/challenges_created/new 

I receive the message

Showing /home/james/Code/Rails/test_models/app/views/challenges_created/_form.html.erb where line #1 raised:

undefined method `user_challenges_path' for #<#    <Class:0x007fb154de09d8>:0x007fb1500c0f90>
Extracted source (around line #1):

1: <%= form_for [@user, @challenge] do |f| %>
2:   <% if @challenge.errors.any? %>

The result is the same for the edit action too. I have tried many things but if I were to reference @challenge_created in the form_for then it is not matching the Challenge model.

Can anybody please advise on how what I am doing wrong. Thank you in advance. My schema is:

  create_table "users", :force => true do |t|
    t.string   "name"
    t.datetime "created_at",    :null => false
    t.datetime "updated_at",    :null => false
    t.integer  "challenger_id"
    t.integer  "supporter_id"
  end

  create_table "challenges", :force => true do |t|
    t.string   "title"
    t.text     "description"
    t.integer  "duration"
    t.date     "completion_date"
    t.string   "status"
    t.datetime "created_at",      :null => false
    t.datetime "updated_at",      :null => false
    t.integer  "challenger_id"
    t.integer  "supporter_id"
  end
  • 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-12T01:16:18+00:00Added an answer on June 12, 2026 at 1:16 am

    I think the problem is that you have a challenge_created controller, but you do not have model for it. In you form you specify a user and a challenge so rails tries to find a controller for challenge, not challenge_created. Rails thinks that for a model you have a controller named based on the convention.

    I recommend you not to create two different controllers for challenges. Use only one and differenciate on actions. E.g. ou can create a list_created and list_supported action in challenges.

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

Sidebar

Related Questions

I have a Lexicon model, and I want user to be able to create
I want the user to be able to create polygons after placing some (unknown
I want a user to be able to create an account and upload a
I want to build a game which the user can be able to create
I want the user to be able to see the source code of the
I want the user to be able to make some preferences like colors, prefered
I want the user to be able to see my application in the menu
I want the user to be able to enter a name for a file
I want the user to be able to select an option, which would change
I want my user to be able to hit the submit button and have

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.