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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:43:23+00:00 2026-05-11T21:43:23+00:00

redirect_to :controller=>’groups’,:action=>’invite’ but I got error because redirect_to send GET method I want to

  • 0
    redirect_to :controller=>'groups',:action=>'invite'

but I got error because redirect_to send GET method I want to change this method to ‘POST’ there is no :method option in redirect_to what will I do ? Can I do this without redirect_to.

Edit:

I have this in groups/invite.html.erb

<%= link_to "Send invite", group_members_path(:group_member=>{:user_id=>friendship.friend.id,  :group_id=>@group.id,:sender_id=>current_user.id,:status=>"requested"}), :method => :post %>

This link call create action in group_members controller,and after create action performed I want to show groups/invite.html.erb with group_id(I mean after click ‘send invite’ group_members will be created and then the current page will be shown) like this:

redirect_to :controller=>'groups',:action=>'invite',:group_id=>@group_member.group_id

After redirect_to request this with GET method, it calls show action in group and take invite as id and give this error

Couldn't find Group with ID=invite

My invite action in group

    def invite
@friendships = current_user.friendships.find(:all,:conditions=>"status='accepted'")
@requested_friendships=current_user.requested_friendships.find(:all,:conditions=>"status='accepted'")
@group=Group.find(params[:group_id])
 end

The solution is I have to redirect this with POST method but I couldn’t find a way.

Ugly solution: I solved this problem which I don’t prefer. I still wait if you have solution in fair way.

My solution is add route for invite to get rid of ‘Couldn’t find Group with ID=invite’ error.

in routes.rb

   map.connect "/invite",:controller=>'groups',:action=>'invite'

in create action

   redirect_to "/invite?group_id=#{@group_member.group_id}"

I call this solution in may language ‘amele yontemi’ in english ‘manual worker method’ (I think).

  • 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-11T21:43:23+00:00Added an answer on May 11, 2026 at 9:43 pm

    It sounds like you are getting tripped up by how Rails routing works. This code:

    redirect_to :controller=>'groups',:action=>'invite',:group_id=>@group_member.group_id
    

    creates a URL that looks something like /groups/invite?group_id=1.

    Without the mapping in your routes.rb, the Rails router maps this to the show action, not invite. The invite part of the URL is mapped to params[:id] and when it tries to find that record in the database, it fails and you get the message you found.

    If you are using RESTful routes, you already have a map.resources line that looks like this:

    map.resources :groups
    

    You need to add a custom action for invite:

    map.resources :groups, :member => { :invite => :get }
    

    Then change your reference to params[:group_id] in the #invite method to use just params[:id].

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

Sidebar

Related Questions

I want to change the redirect on a create method, but I don't want
When I use redirect_to 'index' in my controller I get the following error. -on
I have a simple method def execperl system(perl myscript.pl) redirect_to :controller => :mycontroller, :action
I want to redirect my '/' uri to a given controller's action. I used
Right now when I want to redirect after an action in my controller I
In a Rails app sometimes you use a redirect in an action... redirect_to :controller
Inside a given controller BobsController - is the controller argument on the redirect_to method
In a Rails controller I'm calling this: redirect_to :controller => user, :action => login
I am new to rails and I have used redirect_to :controller => posts, :action
I have made a JSP page which send request to @controller into method UserList()

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.