# How to pass 2 ids

**URL:** <https://www.ruby-forum.com/t/how-to-pass-2-ids/108416>\
**Category:** Rails\
**Created:** [July 3, 2007, 10:18am UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416 "2007-07-03T10:18:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 10:18am UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/1 "2007-07-03T10:18:28Z")

</div>

Hi,

I want to pass 2 ids to same controller.How can i do this?  
I have following code  
\<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id %\>  
I also want to pass project.id to id

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 10:25am UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/2 "2007-07-03T10:25:21Z")

</div>

> I want to pass 2 ids to same controller.How can i do this?  
> I have following code  
> \<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id %\>  
> I also want to pass project.id to id

Logically you can’t pass 2 ids using the same param…, try using:

\<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id , :project\_id  
=\> @project.id %\>

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 12:10pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/3 "2007-07-03T12:10:51Z")

</div>

Moises D. wrote:

> > I want to pass 2 ids to same controller.How can i do this?  
> > I have following code  
> > \<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id %\>  
> > I also want to pass project.id to id
> 
> Logically you can’t pass 2 ids using the same param…, try using:
> 
> \<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id , :project\_id  
> =\> @project.id %\>

Thanks Moises D.,

It’s working.But i am not able to use that second id in my controller.

redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
params[:project\_id]

This line gives the error.

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 12:13pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/4 "2007-07-03T12:13:26Z")

</div>

> It’s working.But i am not able to use that second id in my controller.
> 
> redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> params[:project\_id]
> 
> This line gives the error.

Can you show the entire code for the action “delete” and the log of the  
error…

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/5 "2007-07-03T12:32:45Z")

</div>

Moises D. wrote:

> > It’s working.But i am not able to use that second id in my controller.
> > 
> > redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> > params[:project\_id]
> > 
> > This line gives the error.
> 
> Can you show the entire code for the action “delete” and the log of the  
> error…

Hi,  
Here is the code i m using  
This is the link from which i m calling delete:  
\<%= link\_to “delete”, :action =\> “delete”, :id =\> project.id, :mt =\>  
@met.id %\>

And this is delete action

def delete  
@project = Project.find(params[:id])  
@project.delete  
redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
params[:mt]

This is the log:

NoMethodError in Project#list  
Showing app/views/project/list.rhtml where line #21 raised:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.name

Extracted source (around line #21):

18:

  
19:  
20:   
21: \<%= link\_to projects.met.name, :controller =\> “met”, :action  
=\>“show”, :id =\> projects.met.id %\>  
22:   
23:  
24: \<%= link\_to projects.title, :action =\> “show”, :id =\>  
projects.id %\>

RAILS\_ROOT: ./script/…/config/…

Application Trace | Framework Trace | Full Trace  
#{RAILS\_ROOT}/app/views/project/list.rhtml:21:in  
`_run_rhtml_47app47views47project47list46rhtml' #{RAILS_ROOT}/app/views/project/list.rhtml:16:in`each’  
#{RAILS\_ROOT}/app/views/project/list.rhtml:16:in  
`_run_rhtml_47app47views47project47list46rhtml' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:326:in`send’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/base.rb:326:in  
`compile_and_render_template' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:301:in`render\_template’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/base.rb:260:in  
`render_file' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:806:in`render\_file’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:711:in  
`render_with_no_layout' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/layout.rb:247:in`render\_without\_benchmark’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:50:in  
`render' C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:50:in  
`render' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1096:in`perform\_action\_without\_filters’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:632:in  
`call_filter' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:634:in`call\_filter’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:619:in  
`perform_action_without_benchmark' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/rescue.rb:83:in  
`perform_action' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`send’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`process_without_filters' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in`process\_without\_session\_management\_support’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/session\_management.rb:114:in  
`process' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in  
`dispatch' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`synchronize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in  
`process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`each’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`initialize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`new’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`initialize’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`new' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`each’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in`load’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:488:in  
`load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:488:in  
`load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
C:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in`require’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in`require’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39  
C:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3  
#{RAILS\_ROOT}/app/views/project/list.rhtml:21:in  
`_run_rhtml_47app47views47project47list46rhtml' #{RAILS_ROOT}/app/views/project/list.rhtml:16:in`each’  
#{RAILS\_ROOT}/app/views/project/list.rhtml:16:in  
`_run_rhtml_47app47views47project47list46rhtml' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:326:in`send’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/base.rb:326:in  
`compile_and_render_template' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:301:in`render\_template’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/base.rb:260:in  
`render_file' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:806:in`render\_file’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:711:in  
`render_with_no_layout' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/layout.rb:247:in`render\_without\_benchmark’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:50:in  
`render' C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:50:in  
`render' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1096:in`perform\_action\_without\_filters’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:632:in  
`call_filter' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:634:in`call\_filter’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:619:in  
`perform_action_without_benchmark' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/rescue.rb:83:in  
`perform_action' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`send’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`process_without_filters' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in`process\_without\_session\_management\_support’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/session\_management.rb:114:in  
`process' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in  
`dispatch' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`synchronize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`process’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in  
`process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`each’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`initialize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`new’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`initialize’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`new' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`each’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in`run’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in`load’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:488:in  
`load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:488:in  
`load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
C:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in`require’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in`require’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39  
C:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3  
Request  
Parameters: None

Show session dump

* * *

:user: 202  
flash: !map:ActionController::Flash::FlashHash {}

Response  
Headers: {“cookie”=\>[], “Cache-Control”=\>“no-cache”}

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 12:48pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/6 "2007-07-03T12:48:02Z")

</div>

> \<%= link\_to “delete”, :action =\> “delete”, :id =\> project.id, :mt =\>  
> @met.id %\>
> 
> def delete  
> @project = Project.find(params[:id])  
> @project.delete  
> redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> params[:mt]
> 
> This is the log:
> 
> NoMethodError in Project#list  
> Showing app/views/project/list.rhtml where line #21 raised:
> 
> You have a nil object when you didn’t expect it!  
> The error occurred while evaluating nil.name
> 
> Extracted source (around line #21):
> 
> 18:
> 
>   
> 19:  
> 20:   
> 21: \<%= link\_to projects.met.name, :controller =\> “met”, :action  
> =\>“show”, :id =\> projects.met.id %\>  
> 22:   
> 23:  
> 24: \<%= link\_to projects.title, :action =\> “show”, :id =\>  
> projects.id %\>
> 
> The link it’s ok, the redirect\_to seems to be ok, but how can you get an  
> error on the app/views/project/list.rhtml if you are redirecting to the  
> ‘proj’ action?.
> 
> The error in the list action seems to be that the projects variable  
> don’t have a met associated and then return nil and the name method for  
> nil isn’t defined and creates an exception…
> 
> Can you post the code for the view and action list…

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 4, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/7 "2007-07-04T18:25:33Z")

</div>

Mahendra W. wrote:

> I want to pass 2 ids to same controller.How can i do this?  
> I have following code  
> \<%= link\_to “delete”, :action =\> “delete”, :id =\> @met.id %\>  
> I also want to pass project.id to id

The first :id is essentially a convenience, satisfying the most common  
URI:  
controller/action/id. You can add any other :id simply by giving it a  
different name, so:

link\_to “delete”, :action =\> “delete”, :id =\> @met.id, :project\_id =\>  
project.id

Now fetch the second one into the action with params[:project\_id].

–  
Phlip  
[Test Driven Ajax (on Rails) [Book]](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax

---

<div class="post-metadata">

**Author:** ![mahen1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@mahen1981](https://www.ruby-forum.com/u/mahen1981)\
**Post date:** [July 3, 2007, 2:08pm UTC](https://www.ruby-forum.com/t/how-to-pass-2-ids/108416/8 "2007-07-03T14:08:55Z")

</div>

Moises D. wrote:

> > \<%= link\_to “delete”, :action =\> “delete”, :id =\> project.id, :mt =\>  
> > @met.id %\>
> > 
> > def delete  
> > @project = Project.find(params[:id])  
> > @project.delete  
> > redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> > params[:mt]
> > 
> > This is the log:
> > 
> > NoMethodError in Project#list  
> > Showing app/views/project/list.rhtml where line #21 raised:
> > 
> > You have a nil object when you didn’t expect it!  
> > The error occurred while evaluating nil.name
> > 
> > Extracted source (around line #21):
> > 
> > 18:
> > 
> >   
> > 19:  
> > 20:   
> > 21: \<%= link\_to projects.met.name, :controller =\> “met”, :action  
> > =\>“show”, :id =\> projects.met.id %\>  
> > 22:   
> > 23:  
> > 24: \<%= link\_to projects.title, :action =\> “show”, :id =\>  
> > projects.id %\>
> > 
> > The link it’s ok, the redirect\_to seems to be ok, but how can you get an  
> > error on the app/views/project/list.rhtml if you are redirecting to the  
> > ‘proj’ action?.
> > 
> > The error in the list action seems to be that the projects variable  
> > don’t have a met associated and then return nil and the name method for  
> > nil isn’t defined and creates an exception…
> > 
> > Can you post the code for the view and action list…
> > 
> > view code
> > 
> > Projects
> > 
> > | 
> > 
> > \<%= link\_to "Logout", :controller =\> "met", :action =\> "logout" %\>
> > 
> > |
> > 
> > | 
> > 
> > \<%= link\_to "My AccountInfo", :controller =\>"met", :action =\> "edit", :id =\> @met.id %\>
> > 
> > | 
> > 
> > \<%= link\_to "My Project", :controller =\>"project", :action =\> "proj", :id =\> @met.id %\>
> > 
> > | 
> > 
> > \<%= link\_to "My Training", :controller =\>"training", :action =\> "train", :id =\> @met.id %\>
> > 
> > | 
> > 
> > \<%= link\_to "My Resume", :controller =\>"project", :action =\> "res", :id =\> @met.id %\>
> > 
> > |
> > 
> > # **Projects of \<%= @met.name %\>**
> > 
> > \<% @met.projects.each do |project| %\>
> > 
> > \<% end %\>
> > 
> > | 
> > 
> > _ **Title** _
> > 
> > | 
> > 
> > _ **Primary Skills** _
> > 
> > | 
> > 
> > _ **Description** _
> > 
> > | 
> > 
> > _ **Duration From** _
> > 
> > | 
> > 
> > _ **Till** _
> > 
> > |
> > | \<%= link\_to project.title, :action =\> "edit", :id =\> project.id %\> | \<%= project.primary\_skills %\> | \<%= project.description%\> | \<%= project.duration\_from%\> | \<%= project.duration\_till%\> | \<%= link\_to "delete", :controller =\>"project", :action =\> "delete", :id =\> project.id, :mt =\> @met.id %\> |
> > 
> > \<%= link\_to "Add new project", :action =\> "new", :id =\> @met.id %\>
> > 
> > \<%= link\_to "Edit all project", :action =\> "editall", :id =\> @met.id %\>
> > 
> > action code:
> > 
> > class ProjectController \< ApplicationController  
> > require ‘win32ole’  
> > layout “standard-layout”  
> > scaffold :project
> > 
> > def new  
> > @project = Project.new  
> > @mets = Met.find(@params[“id”])  
> > end
> > 
> > def update  
> > @project = Project.find(params[:id])  
> > @project.save  
> > if @project.update\_attributes(params[:project])  
> > redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> > @project.met\_id  
> > else  
> > render\_action ‘edit’  
> > end  
> > end
> > 
> > def delete  
> > @project = Project.find(params[:id])  
> > @project.delete  
> > redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> > params[:mt]
> > 
> > ```
> > end
> > 
> > ```
> > 
> > def updateall  
> > @project = Project.find(params[:id])  
> > @project.save  
> > if @project.update\_attributes(params[:project])  
> > redirect\_to :controller =\>‘project’, :action =\> ‘editall’, :id =\>  
> > @project.met\_id  
> > else  
> > render\_action ‘editall’  
> > end  
> > end
> > 
> > def edit  
> > @project = Project.find(@params[“id”])  
> > @mets =Met.find\_all  
> > if session[:user] != @project.met\_id  
> > redirect\_to :controller =\>‘met’, :action =\> ‘login’  
> > end  
> > end
> > 
> > def editall  
> > @met =Met.find(params[:id], :include =\> :projects)  
> > end
> > 
> > def submitP  
> > @project = Project.find(params[:id])  
> > redirect\_to :controller =\>‘project’, :action =\> ‘proj’, :id =\>  
> > @project.met\_id  
> > end
> > 
> > def list  
> > @project = Project.find\_all  
> > @mets =Met.find\_all  
> > end
> > 
> > def proj  
> > @met =Met.find(params[:id], :include =\> :projects)  
> > if session[:user] != @met.id  
> > redirect\_to :controller =\>‘met’, :action =\> ‘login’  
> > end  
> > end
> > 
> > def create  
> > @project = Project.new(params[:project])  
> > if @project.save  
> > redirect\_to :action =\> ‘proj’, :id =\> @project.met\_id  
> > else  
> > redirect\_to :action =\> ‘new’, :id =\> @project.met\_id  
> > end  
> > end
> > 
> > def delete  
> > Project.find(@params[‘id’]).destroy  
> > redirect\_to :action =\> ‘list’  
> > end
> > 
> > def res  
> > @met =Met.find(params[:id], :include =\> [:projects, :trainings,  
> > :gaps])  
> > if session[:user] != @met.id  
> > redirect\_to :controller =\>‘met’, :action =\> ‘login’  
> > end
> > 
> > # @train = @met.trainings.find(params[:id])
> > 
> > # @train = Training.find(@params[“id”])
> > 
> > end
> > 
> > def resume  
> > @met =Met.find(params[:id], :include =\> [:projects, :trainings,  
> > :gaps])  
> > end
> > 
> > end
