Add custom GET Parameter logic to restful class in Ruby on Rails

252 views Asked by At

I have a UsersController and RegistrationsController to handle user signups with Devise in rails.

I am adding code for affiliate sign ups, in order to map users to affiliates using a custom HTTP GET parameter called "a".

So for example, I want my sign up to respond like this: www.app.com/users/sign_up?a=affiliate_code

However, Rails doesn't respond to params[:a] in the controller. In my routing file, all I have is resources :users

What is the easiest and most rails way to implement this?

2

There are 2 answers

0
Matteo Alessani On

You need to setup the action sign_up in routes.rb or you can use the default new method to create a user. Then you should get the params 'a' without problem.

0
tjeden On

Add this line to routes:

match 'users/sign_up', :to => 'users#new'