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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:04+00:00 2026-05-25T20:21:04+00:00

I have my models setup as follows: class User has_many :memberships, :dependent => :destroy

  • 0

I have my models setup as follows:

 class User
 has_many :memberships, :dependent => :destroy
 has_many :groups, :through => :memberships

 Class Group
 has_many :memberships, :dependent => :destroy
 has_many :users, :through => :memberships

 Class Membership
 attr_accessible :user_id, :group_id
 belongs_to :user
 belongs_to :group

My MembershipController#create

def create
  @membership = current_user.memberships.build(:group_id => params[:group_id])
  if @membership.save
    flash[:notice] = "You have joined this group."
    redirect_to :back
  else
    flash[:error] = "Unable to join."
    redirect_to :back
  end
end

I have resources :memberships in my routes so that it can find the create action.

Finally in my Group#show action I want a user to be able to join a group. So I created this form_tag

<%= form_tag(membership_path) do %>
    <%= hidden_field_tag @group.id %>
    <%= submit_tag "Join Group"%>
<% end %>

This returns the following error:

Routing Error

No route matches [POST] "/memberships/1"

I have run a rake routes to try and understand what I am missing here:

memberships GET /memberships(.:format) {:action=>”index”, :controller=>”memberships”}
POST/memberships(.:format) {:action=>”create”, controller=>”memberships”}
new_membership GET /memberships/new(.:format) {:action=>”new”,controller=>”memberships”}
edit_membership GET /memberships/:id/edit(.:format){:action=>”edit”, controller=>”memberships”}

membership GET /memberships/:id(.:format) {:action=>”show”, :controller=>”memberships”}
PUT /memberships/:id(.:format){:action=>”update”, :controller=>”memberships”}
DELETE /memberships/:id(.:format) {:action=>”destroy”, :controller=>”memberships”}

Anyone see the error of my ways?

  • 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-25T20:21:04+00:00Added an answer on May 25, 2026 at 8:21 pm

    Don’t you want to be posting to memberships_path rather than membership_path? It looks like the error is indicating it can’t find a POST route for a membership due to the fact that there is actually no route for :membership for POST, :only memberships.

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

Sidebar

Related Questions

Lets say I have some view models set up as follows: public class User
I have some models setup as follows: public class Form { public int FormId
I have following models setup in my Django application class School(models.Model): name = models.TextField()
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
I have this setup in my models: class Author(models.Model): name = models.CharField(max_length=100) class Topic(models.Model):
I have a two models set up like this: class User < ActiveRecord::Base #
I have a model that is set up as follows: class Log(models.Model): name =
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
Suppose I have my models set up already. class books(models.Model): title = models.CharField... ISBN
I have the following models set up: class Contact < ActiveRecord::Base belongs_to :band belongs_to

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.