# Params in controllers

**URL:** <https://www.ruby-forum.com/t/params-in-controllers/85037>\
**Category:** Rails\
**Created:** [February 9, 2007, 1:34pm UTC](https://www.ruby-forum.com/t/params-in-controllers/85037 "2007-02-09T13:34:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nyxx](https://www.ruby-forum.com/u/nyxx)\
**Post date:** [February 9, 2007, 1:34pm UTC](https://www.ruby-forum.com/t/params-in-controllers/85037/1 "2007-02-09T13:34:31Z")

</div>

Hey people,

Back with another simple question…

How can I access a paramater inside my controller which is provided  
through the url. I am doing the following inside my view:

\<%= link\_to “signup”, :controller =\> “account”, :action =\> “signup”,  
:type =\> “candidate” %\>

iside my account controller I have the following:

def signup  
if params[:type] == “candidate”  
@candidate = Candidate.new(params[:candidate])  
return unless request.post?  
@candidate.save!  
self.current\_candidate = @candidate  
elsif params[:type] == “landlord”  
@landlord = Landlord.new(params[:landlord])  
return unless request.post?  
@landlord.save!  
self.current\_landlord = @landlord  
end  
redirect\_back\_or\_default(:controller =\> ‘home’, :action =\> ‘index’)  
rescue ActiveRecord::RecordInvalid  
render :action =\> ‘signup’  
end

It doesn’t want to access the params[:type] variable, but it also does  
not generate an error, possibly because the actual code is not false.

Many thanks,

- Danny

---

<div class="post-metadata">

**Author:** ![nyxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nyxx](https://www.ruby-forum.com/u/nyxx)\
**Post date:** [February 9, 2007, 2:15pm UTC](https://www.ruby-forum.com/t/params-in-controllers/85037/2 "2007-02-09T14:15:34Z")

</div>

when you mouse over the link, do you see the parameter on the end of the  
URL?

[http://www.mysite.com/account/signup?type=candidate](http://www.mysite.com/account/signup?type=candidate)

or if using a route like ‘/account/signup/:type’

[http://www.mysite.com/account/signup/candidate](http://www.mysite.com/account/signup/candidate)

do you see it in the source from the browser?

watching your development.log, do you see the parameter when the link  
is clicked?

---

<div class="post-metadata">

**Author:** ![nyxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nyxx](https://www.ruby-forum.com/u/nyxx)\
**Post date:** [February 9, 2007, 2:39pm UTC](https://www.ruby-forum.com/t/params-in-controllers/85037/3 "2007-02-09T14:39:39Z")

</div>

Chris H. wrote:

> when you mouse over the link, do you see the parameter on the end of the  
> URL?
> 
> [http://www.mysite.com/account/signup?type=candidate](http://www.mysite.com/account/signup?type=candidate)
> 
> or if using a route like ‘/account/signup/:type’
> 
> [http://www.mysite.com/account/signup/candidate](http://www.mysite.com/account/signup/candidate)
> 
> do you see it in the source from the browser?
> 
> watching your development.log, do you see the parameter when the link  
> is clicked?

yeah I do see the parameter in the url.

[http://127.0.0.1:3000/account/signup?type=candidate](http://127.0.0.1:3000/account/signup?type=candidate)

But is the parameter still accessible after I submit the form which has  
the action signup in the account controller??

---

<div class="post-metadata">

**Author:** ![nyxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nyxx](https://www.ruby-forum.com/u/nyxx)\
**Post date:** [February 9, 2007, 3:00pm UTC](https://www.ruby-forum.com/t/params-in-controllers/85037/4 "2007-02-09T15:00:29Z")

</div>

Processing AccountController#signup (for 127.0.0.1 at 2007-02-09  
14:57:10) [POST]  
Session ID: 68d0c5bdc1fc8688e10718fcd2c235fb  
Parameters: {“commit”=\>“Aanmelden”,  
“candidate”=\>{“email\_confirmation”=\>“removed\_email\_address@domain.invalid”,  
“password\_confirmation”=\>“1234”, “lastname”=\>“12345”,  
“firstname”=\>“12345”, “mobile”=\>“0612345678”,  
“date\_of\_birth”=\>“01-01-2001”, “telephone”=\>“02012345678”,  
“password”=\>“1234”, “email”=\>“removed\_email\_address@domain.invalid”}, “action”=\>“signup”,  
“controller”=\>“account”}  
Redirected to [http://127.0.0.1:3000/](http://127.0.0.1:3000/)  
Completed in 0.00194 (515 reqs/sec) | DB: 0.00000 (0%) | 302 Found  
[[http://127.0.0.1/account/signup](http://127.0.0.1/account/signup)]

see it doesn’t show the :type parameter, but is the following  
possible…

instead of if/elsing the :type parameter I check if the :candidate or  
the :landlord array exists… Going to try that now…
