1

I'm having problems passing parameters (in this case, @plan_id) to the next page (new_user_url).

class SubscriptionsController < ApplicationController
  #before_filter :require_admin!, :except => [:show]
  skip_before_filter :authenticate_user!, :only => [ :create ]

  def create
    @plan_id = params[:plan]
    if current_user.nil?
      redirect_to new_user_url, :plan_id => @plan_id     
    end
  end
end



class UsersController < ApplicationController
  skip_before_filter :authenticate_user!, :only => [ :new, :create ]
  before_filter :require_admin!, :only => [ :index, :show, :destroy, :signin_as ]

  def new
    logger.debug params
    @user = User.new
    @plan_id = params[:plan_id]
    logger.debug "-------------- plan id: #{@plan_id}"
    @plan = Plan.plan @plan_id
  end

What I see in the debug message is

Processing UsersController#new (for 127.0.0.1 at 2011-01-14 16:07:50) [GET]
  Parameters: {"subdomains"=>["secure"], "controller"=>"users", "action"=>"new"}
{"subdomains"=>["secure"], "controller"=>"users", "action"=>"new"}
-------------- plan id: 

Any pointers to what I'm doing wrong would be much appreciated.

Thanks!

1 Answer 1

2

The way you've written your redirect_to call, you're passing the plan_id parameter to the response_status argument. Look at redirect_to documentation:

redirect_to(options = {}, response_status = {}) 

You probably meant to write:

redirect_to new_user_url(:plan_id => @plan_id)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.