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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:46:06+00:00 2026-06-12T16:46:06+00:00

I have two models for users ; the Plans model has_many users. Now, what

  • 0

I have two models for users ; the Plans model has_many users. Now, what I would like to do is to allow users to upgrade/downgrade their plans, by changing the plan_id. I’ve set up a form, as well as the appropriate action, but when I hit submit, it doesn’t seem to do what the PUT action says. It seems to use the update action.

Here’s my form :

                       <%= form_tag("/users/update_plan", :method => "put" ) do %>

                        <%= hidden_field_tag :plan_id, plan.id %>

                        <%= submit_tag("Change To Plan", :class => "signup") %>


                      <% end %>

Here’s my update action

  def update_plan
   @user = current_user
   @user.plan_id = params[:plan_id]
   @user.save
   sign_in @user
   redirect_to change_plan
  end   

When I submit the form above though, it not only doesn’t register the change, but I think it uses the update action, and not the update_plan action. The reason I think this is because it redirects to the what’s in the update action, and it flashes the same thing as the update action.

  def update
    @user = current_user
    if @user.update_attributes(params[:user])
      flash[:success] = "Profile updated"
      sign_in @user
      redirect_to edit_user_path(@user)
    else
      render 'edit'
    end
  end    

Here’s my routes.rb file

Dentist::Application.routes.draw do

  resources :users
  resources :sessions, only: [:new, :create, :destroy]
  resources :phones, only: [:new, :create, :destroy]
  resources :find_numbers, only: [:new, :create, :destroy]  

  put 'users/update_plan'
  match '/signup',  to: 'users#new'
  match '/login',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete
  match '/change_plan',  to: 'users#change_plan'

  root  to: 'static_pages#home'

  match '/product_demo', to: 'static_pages#product_demo'

  match '/pricing', to: 'plans#index'

  match '/contact', to: 'static_pages#contact'

And here’s a console screenshot of what’s happening:

http://stepanp.com/debug3.jpg

It seems to say it’s using the update_plan action, but… :S

Any help on trying to get Update_plan action to function would be greatly 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-12T16:46:07+00:00Added an answer on June 12, 2026 at 4:46 pm

    The form is going to the right place (/users/update_plan), but that is being routed to:

    UsersController#update
    

    as it says on the second line of your console log. So not the action you expect, and the problem is in your routes. Try this to list all your routes:

    rake routes
    

    Probably the users update route (created by resources :users) is catching this first:

    PUT    /users/:id(.:format)                                   users#update
    

    There are no restrictions on the content of id, and format is optional, so users/update_plan would call users/update with an id of update_plan (in fact you can see that is happening at the edge of your console log screenshot, look for the :id => parameter).

    So I would move your custom route to the top of the routes file first above resources :users, and also try change it to direct to the action you want, not sure what a route with no action specified does…

     put '/users/update_plan',  to: 'users#update_plan'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models: User has_many :prices Price belongs_to :users I want to show
I have two models: USERS has_many :celebrations has_many :boards, :through => :celebrations BOARDS has_many
I have two Models - Users and Restaurants. They can set tweets like status
I have two models related as follows. USERS has_many :celebrations has_many :boards, :through =>
I have two models: countries and users country.rb class Country < ActiveRecord::Base has_many :users
I have two models - Tenant and User, each tenant will have_many users and
I have two models: User and Car with the following associations: User has_many Car
I have two models User and Category that have a HABTM association. I would
I have two models Users and Roles . I have setup a many to
I have two models, users and themes, that I'm currently joining in a HABTM

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.