Ruby on Rails, How would I update a variable passed to a view with a helper form? -


controller creates @variable

def main  @variable = "people awesome!" end 

the view presents @variable header

<h1><%= @variable %></h1> <%= form_for(@variable) |f| %>  <%= f.text_field :variable%>  <%= f.submit "change header"%> <%end%> 

here's routes.rb looks like

#testarea  'test' => 'testscripts#main'  post 'test' => 'testscripts#main' 

would able update header without passing submission whole different view?

thank in advance. appreciate time.

you can following

def main @variable = variable.new end 

Comments