ruby - What is ivar in Rails controller? -


i can see ivar term mentioned many times here https://github.com/rails/rails/issues/18950#issuecomment-77924771 can't find straight forward explanation ivar.

what , can term used outside controller context?

ivar stands instance variable. instance variable bound object of given class and, in rails, used in controllers , views.

this github issue have posted: 'ivars serve recommended "api" between controllers , views.'

for example in controller:

def new   @post_ivar = post.new end 

you can use 'ivar' in view new action, i.e. new.haml:

= form_for @post_ivar |f|   = f.text_field :headline   -# ... 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -