I define
@variable1= '1'
in controller. In view, i call <%=@variable1%> and it show 1. Now I click button to call
def change_variable
@variable1= '2'
end
what do I do to see '2' in view?
The ruby code you have posted only runs at the time the page is being generated.
Once it is sent to the browser it becomes a static page.
In order to run the change_variable method you are referring to an http request of some description needs to be made (e.g. submit button, XMLHttpRequest etc.)
If you want the variables to change on the actual page, you will need to look into some javascript solutions.
change_variableaction.