Hi,
I am trying to pass some parameters from one controller method to a
method in a different controller , using the rediret_to method. My
code is something like this
controllerA
def method1
id =(params[''user_name''])
redirect_to({:controller => "controllerB", :action =>
"method2"}, :user=>id)
end
controllerB
def method2 user
@user=user
end
However this doesn''t seem to be working , because in view when I use
<
%= @user%> to display the user name , I get the error : wrong number
of arguments (0 for 1)
Any clue , where am going wrong.
TIA
~shishir
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
controllerA
============ def method1
id =(params[''user_name''])
redirect_to({:controller => "controllerB", :action =>
"method2", :user=>id } ) # put the :user INSIDE the path hash.
end
controllerB
============ def method2 user # DONT NEED THIS
def method2 # without the user parameter
@user=params[''user''] #--> the parameter is passed
automatically via the
params hash; no need to define the parameter in the def clause.
end
enjoy
--
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
-~----------~----~----~----~------~----~------~--~---
Thanks Shai !! It worked :) ~shishir On Oct 21, 8:52 pm, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> controllerA > ============> def method1 > id =(params[''user_name'']) > redirect_to({:controller => "controllerB", :action => > "method2", :user=>id } ) # put the :user INSIDE the path hash. > end > > controllerB > ============> def method2 user # DONT NEED THIS > def method2 # without the user parameter > @user=params[''user''] #--> the parameter is passed automatically via the > params hash; no need to define the parameter in the def clause. > end > > enjoy > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---