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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:18:23+00:00 2026-06-12T12:18:23+00:00

I currently have a user system set up with 2 models –> The Plans

  • 0

I currently have a user system set up with 2 models –> The Plans Model has_many Users.

What I would like to implement is a way to allow the users to upgrade/downgrade their plans. To do this, I’ve created a POST action in the controller called “update_plan”, and when the user POSTs a new Plan_id to it, than the user’s plan_id would change, and hence would be subscribed to a different plan.

When I POST to the Update-plan controller though the plan_id for the user does not change. I verified this by going to the console, and doing

user = User.find(1)
user.plan.id 

When checking the plan_id the second time, there was no change.

Here’s what my form looks like for changing the plan id

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

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

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


                      <% end %>

And here’s the Update Plan Action, in the Users Controller

  def update_plan
    @user = current_user
    if @user.update_attributes(params[:plan_id])
      flash[:success] = "Profile updated"
      sign_in @user
      redirect_to change_plan_path
    else
      render change_plan_path
      flash[:errors] = "Oops, something went wrong with the Update. Please Talk To Support"
    end
  end   

I am not quite sure where the error is though, because I’m not too sure in the core I’ve written above.

How would you update the parameters of the user’s plan_id? Any help 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-12T12:18:24+00:00Added an answer on June 12, 2026 at 12:18 pm

    @user.update_attributes(params[:plan_id]) won’t update the user in the way you’re expecting. update_attributes expects a hash which contains keys that match the model’s columns names.

    To update a single column, try this:

    @user = current_user
    @user.plan_id = params[:plan_id]
    @user.save
    

    Another way, is to pass update_attributes a hash with plan_id (assuming plan_id can be mass assigned):

    @user.update_attributes({:plan_id => params[:plan_id]})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have two Backbone models: user and project. I would like to have
I've got some models set up like this: class AppGroup(models.Model): users = models.ManyToManyField(User) class
I currently have two different models: User and Project . The User model has
I currently have User SEO URL's set to Yes in OpenCart Admin. System ->
I currently have built a system that checks user IP, browser, and a random-string
Currently I have my entities working with models that look like: public class MyModel
I currently have a user's table which contains a one-to-one relationship for Youtube OAuth
Currently I have a User table that has a toys_owned column that is an
I currently have three classes User , UserProfile , and Vendor . User is
I currently have a wysiwyg iframe where the user can submit input to another

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.