ruby - Why does rails generate object instance variables in controllers -


Why not use Rail object instance variables instead of just a local pop variable in the generated code? Is there a general situation where it is useful rather than just using a local variable? I think it is understood to use a local variable and attach nothing to the object namespace, unless you need it.

  # gET / poop / 1 # get /poop/1.xml def Show @ POP = POP.Fund (PARAM [IID]) response_to do | Format | Format.html # show.html.erb format.xml {Render: xml = & gt; @poop} End End  

Is there some impending general condition where this is useful Is it simply using a local variable instead?

Of course there is default position is like App / View / Pops / Show. See Automated Source Code (with the use of Script / Generate / Scalp ) in ARB :

.
  & lt; P & gt; & Lt; P & gt; Field: & lt; / P & gt; & Lt;% = h @ poop.field% & gt; & Lt; / P & gt; & Lt;% = link_to 'edit', edit_poop_path (@ poop)%>  

If the variable was local in the controller method, how can the renderer access the element found with the find (params [: id]) ? response_to does not directly call the component that renders the page instead, it delays its execution to that point when the local step is already out of the field. Then the only way that the calculator is done in the Render controller, can communicate with the use of example frequency.


Comments