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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 idLogically you can''t pass 2 ids using the same param..., try using: <%= link_to "delete", :action => "delete", :id => @met.id , :project_id => @project.id %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Moises Deniz 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 Deniz, 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Moises Deniz 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: <tr> 19: 20: <td> 21: <%= link_to projects.met.name, :controller => "met", :action =>"show", :id => projects.met.id %> 22: </td> 23: 24: <td><%= link_to projects.title, :action => "show", :id => projects.id %></td> 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"} -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> <%= 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: <tr> > 19: > 20: <td> > 21: <%= link_to projects.met.name, :controller => "met", :action > =>"show", :id => projects.met.id %> > 22: </td> > 23: > 24: <td><%= link_to projects.title, :action => "show", :id => > projects.id %></td> >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... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Moises Deniz 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: <tr> >> 19: >> 20: <td> >> 21: <%= link_to projects.met.name, :controller => "met", :action >> =>"show", :id => projects.met.id %> >> 22: </td> >> 23: >> 24: <td><%= link_to projects.title, :action => "show", :id => >> projects.id %></td> >> > > 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 <html> <head> <title>Projects</title> </head> <body bgcolor="#FAEBD7"> <table border="0" width="975"> <tr> <td width="100%"><p align="right" style="width:950px;font:9pt,Verdana"><%= link_to "Logout", :controller => "met", :action => "logout" %></td> </tr> </table> <table border="0" align=''center'' width="975"> <tr bgcolor=#DEE5EB> <td width="25%"><p align="left" style="font:9pt,Verdana"><%= link_to "My AccountInfo", :controller =>"met", :action => "edit", :id => @met.id %></td> <td width="25%"><p align="left" style="font:9pt,Verdana"><%= link_to "My Project", :controller =>"project", :action => "proj", :id => @met.id %></td> <td width="25%"><p align="left" style="font:9pt,Verdana"><%= link_to "My Training", :controller =>"training", :action => "train", :id => @met.id %></td> <td width="25%"><p align="left" style="font:9pt,Verdana"><%= link_to "My Resume", :controller =>"project", :action => "res", :id => @met.id %></td> </tr> </table> <h1 style="font:10pt,Verdana" align=center><b>Projects of <%= @met.name %><b></h1> <table border="1" align=''center'' style="font:9pt,Verdana"> <tr> <td width="20%"><p align="center"><i><b>Title</b></i></td> <td width="20%"><p align="center"><i><b>Primary Skills</b></i></td> <td width="40%"><p align="center"><i><b>Description</b></i></td> <td width="10%"><p align="center"><i><b>Duration From</b></i></td> <td width="10%"><p align="center"><i><b>Till</b></i></td> </tr> <% @met.projects.each do |project| %> <tr> <td><%= link_to project.title, :action => "edit", :id => project.id %> </td> <td><%= project.primary_skills %> </td> <td><%= project.description%> </td> <td><%= project.duration_from%> </td> <td><%= project.duration_till%> </td> <td><%= link_to "delete", :controller =>"project", :action => "delete", :id => project.id, :mt => @met.id %> </td> </tr> <% end %> </table> <p style="font:9pt,Verdana"><%= link_to "Add new project", :action => "new", :id => @met.id %></p> <p style="font:9pt,Verdana"><%= link_to "Edit all project", :action => "editall", :id => @met.id %></p> <br><br><br> </body> </html> 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mahendra Waykole 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 idThe 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 http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---