Ritz Coder
2006-Aug-17 18:59 UTC
[Rails] confused about scoping in controller when using render
Hi. Can anyone tell me why I cannot access the testmethod inside my
change controller? Thanks very much for any help. I get an undefined
method error. If I call the method outside the render :update (as in
the comments) it works fine. Thanks very much.
---- view ----
<%= javascript_include_tag :defaults %>
<div id="result">testing</div>
<%= link_to_remote ''change'', :url => { :action =>
:change } %>
---- controller ----
class TheController < ApplicationController
def index
end
def change
# no error here testmethod returns correctly
x = testmethod()
render :update do |page|
# error - test method undefined.
page.replace_html ''result'', testmethod()
#page.replace_html ''result'', x
end
end
def testmethod
"testing here"
end
end
--
Posted via http://www.ruby-forum.com/.
