Peter Hickman wrote:
> you could create a method called
>
> def leading_zeros(number)
> "%05d" % number
> end
>
> and then call it
>
> "#{leading_zeros order.id}#{order.name}"
>
Thanks Peter!
I put the method in the application_helper.rb file:
----
def leading_zeros(number)
"%05d" % number
end
----
And then put the following like you said:
----
#{leading_zeros order.id} #{order.name}"
----
It's giving me this error when I refresh my view:
----
NoMethodError in Orders#index
Showing app/views/orders/index.html.erb where line #9 raised:
undefined method `leading_zeros' for "00009":String
----
Any ideas? Thanks again for all your help.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment