Instant Variables in Ruby on Rails

Hello friend we often require instant variable which we need to call in our entire application for dynamic content .Here is solution for that , just declare this method in application.rb (controller), put in before_filter:settinginstantvars. This is done have fun with instant variable.
def settinginstantvars()
@model = Model.find(:all);
@model.each do |c|

When you need them just do @name (name of field in your table).
Have fun.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s