Topic: derived columns/attributes
I have a model named link, which contains the columns name (for building the url, e.g. this_is_a_link) and description (which is shown to the user, e.g. This is a link).
Now i have two questions:
1. A Link should be created like this: Link.create(:name => 'This is a link'). Internally, the model should set description=name.downcase.strip.gsub(' ', '_'), where can i realize this? I tried the initialize-method of class link, but i didn't succeed.
2. A link should have the method url() (http://mywebsite.de/whatever/this_is_a_link), which should use a named route or url_for method. But these methods i can only use in controller and helper methods, so must i place such a method there?
Thanks at all and excuse for my bad english .