a couple things:
(A) if you want to specifically call the :create method for an object,
it doesn''t matter which controller u call it from (i.e,
ExampleClass.create.... will work whatever controller u put it in) - so
if this is what u want, u''r done
==============
(B) if you want to call any method from one controller to the other,
consider the two possiblities:
(B1) heirarchy -
as all controllers inherit from ApplicationController, you can make a
controller inherit from a different controller, which will pass the
methods along the line of heirarchy, such as
Class ExampleController < OtherController
def a
b # will work
"apples"
end
end
Class OtherController < ApplicationController
def b
a # wont work
"bannanas"
end
end
==============
(B2) consider using a module; you can mix in methods from a module
into both controllers, using require and inlcude respectively:
module MixMe # put this in the /lib folder
def a
"carrots"
end
def b
"dung"
end
end
require ''mix_me''
Class ExampleController < ApplicationController
include MixMe # mixes in the module
def some_method
a # works
b # works
render_text "success.."
end
end
require ''mix_me''
Class OtherController < ApplicationController
include MixMe # mixes in the same module
def some_other_method
a # works
b # works
render_text "success!"
end
end
and, walla - should work perfectly.
==============
pick u''r choose.
(D) good luck
:)
shai
--
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
-~----------~----~----~----~------~----~------~--~---