I'm updating the value of a virtual attribute in my view but this is not being reflected in the model instance.
For example:
MyModel.erb
attr_accessor_with_default :hello_world, false
View.html.erb
<%= @mymodel.hello_world %><br/>
<%
if ( @mymodel.hello_world == false )
@mymodel.hello_world = true
end
%>
<%= @mymodel.hello_world %>
The view outputs:
false
true
However, when I reload the page the same output is shown, when it should be:
true
true
I am seeing the above behaviour in an edit form. When I submit the form (with validation errors) it reloads (displaying errors) but the value for hello_world is not being updated.
Do you have any suggestions? What should I do to get the desired behaviour?