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 %>

testing

<%= 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs