Colin Law wrote:
> Rather than attempt to add a method to the String class, which is what
> you seem to be suggesting, You could add a method to your model that
> returns the id and name as a formatted string.  So in order.rb
> something like
> def order_code
>   "#{'%05d' % id} #{name}"
> end
> Then in the view just use
> <%= @order.order_code %>

Hi Colin,

Would this work if I wanted to put the leading zeros elsewhere in my app 
(other views tied to other models and controllers)? Would I just 
reference the Order model and then do this?

Thanks for your help,

--Matt
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to