Wednesday, 21 October 2015

creating instance based on model name :



var_name = Admin::User.model_name.param_key

# var_name is admin_user

to make admin_user as instance variable:

instance_variable_set("@#{var_name}", Admin::User.last)

now,

@admin_user give you a last record of Admin::User model.

wow...........

No comments:

Post a Comment