Saturday 15 September 2012

How do i create ruby variable properties? -



How do i create ruby variable properties? -

i using ruby on rails.

i need variable, @slideshow, have properties @slideshow.link, @slideshow.name, , @slideshow.description

i have model/table genpackage has columns image_link, image_name, image_description

i can utilize

@slideshow = genpackage.all

but give me variable properties of @slideshow.image_link, @slideshow.image_name, , @slideshow.image_description

how can properties named without "image_"?

if can alter genpackage, utilize alias_attribute:

alias_attribute(new_name, old_name)

allows create aliases attributes, includes getter, setter, , query methods.

something this:

class genpackage < activerecord::base alias_attribute :link, :image_link alias_attribute :name, :image_name alias_attribute :description, :image_description end

that allow utilize link, name, , description everywhere (getters, setters, queries, forms, ...).

ruby-on-rails ruby variables

No comments:

Post a Comment