On 11 Jun 2011, at 19:06, Distriker wrote:
Hi again, sorry for many questions. In mi HomeController, I have the
"hi" method, in this method I use an "if" for show a different message
for a registered user or a guest. When I call in "home/index" my
method "hi", show me this error message:
"Stack level too deep"
class HomeController < ApplicationController
def hi
...
render 'home/index'
...
end
end
# home/index
<p>Holaaaa</p>
<%= @controller.hi %>
You are rendering home/index which is calling hi which is rendering
home/index which is calling hi which is rendering home/index which is
calling hi which is rendering home/index which is calling hi which is
rendering home/index which is calling hi which is rendering home/index
which is calling hi which is…
The whole thing is wrong anyway. The "hi" method should be a helper
and not a controller method, it shouldn't render anything either.
Using @controller should be avoided for the kind of thing you want to
do (if used at all to start off with, unless you want to show some
logging in your views in development mode)
All you want is
class HomeController < ApplicationController
def index
end
end
class HomeHelper < ApplicationHelper
def hi
....
end
end
# home/index
<p>Holaaaa</p>
<%= hi %>
Best regards
Peter De Berdt
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.