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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:37:10+00:00 2026-06-02T23:37:10+00:00

I get the error undefined method `favorite_relationships_path’ when I display this form: <%= form_for(current_user.favorite_relationships.build(lesson_id:

  • 0

I get the error

undefined method `favorite_relationships_path'

when I display this form:

<%= form_for(current_user.favorite_relationships.build(lesson_id: @lesson.id),
             remote: true) do |f| %>
  <div><%= f.hidden_field :lesson_id %></div>
  <%= f.submit "Favorite", class: "btn btn-large btn-primary" %>
<% end %>

I’m not sure why. I have a controller called favorite_relationships_controller.rb and a model file, favorite_relationship.rb, with the code

class FavoriteRelationship < ActiveRecord::Base
  attr_accessible :lesson_id
  belongs_to :user
  belongs_to :lesson
end

My user model also has:

  has_many :favorite_relationships
  has_many :lessons, :through => :favorite_relationships

I’m really not sure why im getting that error. Help would be appreciated.

  • 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-02T23:37:11+00:00Added an answer on June 2, 2026 at 11:37 pm

    Defining controllers, actions and views is not enough. You need to define routes in config/routes.rb to connect URLs to your controllers/actions. Defining RESTful resources with resources :favourite_relationships in your routing file is what causes Rails to generate the *_path and *_url helpers; until you do this there is no way for requests to reach your app, and no way for your app to generate routes based on your models.

    Your routes file should look something like this:

    MyApp::Application.routes.draw do
      resources :favourite_relationships
    end
    

    This generates the typical “CRUD” routes required for a RESTful resource:

    favourite_relationships     GET    /favourite_relationships(.:format)          {:action=>"index", :controller=>"favourite_relationships"}
                                POST   /favourite_relationships(.:format)          {:action=>"create", :controller=>"favourite_relationships"}
     new_favourite_relationship GET    /favourite_relationships/new(.:format)      {:action=>"new", :controller=>"favourite_relationships"}
    edit_favourite_relationship GET    /favourite_relationships/:id/edit(.:format) {:action=>"edit", :controller=>"favourite_relationships"}
         favourite_relationship GET    /favourite_relationships/:id(.:format)      {:action=>"show", :controller=>"favourite_relationships"}
                                PUT    /favourite_relationships/:id(.:format)      {:action=>"update", :controller=>"favourite_relationships"}
                                DELETE /favourite_relationships/:id(.:format)      {:action=>"destroy", :controller=>"favourite_relationships"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the error I get undefined method `followed_users?' for #<User:0x007fdadbf11e28> Extracted source (around
I get this error: undefined method 'vote_sum' for nil:NilClass for this line in my
When i run my features i get this error: undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0>
I get an undefined reference to 'typeof'-error compiling and linking this: #include <stdio.h> #include
When I run php-closure i get a PHP error Undefined index: HTTP_IF_NONE_MATCH in <b>/php-closure.php</b>
In one page of my application I get Type is undefined error on the
Why I get error with this query on my live server but not on
I have this query and I get error Operand should contain 1 column(s), whats
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I have this method form a Rails 2.3.4 app: def self.find_all_colored(query, options={}) finder_options =

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.