Perfect!! That's solved the routing and now it works exactly the way I wanted. Definitely something that needs a blog post this week.
Rich On Thu, Apr 4, 2013 at 5:03 PM, Paul Annesley <[email protected]> wrote: > Have you looked at #to_param on ActiveModel / ActiveRecord? > Also I recommend an equivalent .from_param(param) class method on such > models. > > class Something < AR::Base > def to_param > customer_number > end > def self.from_param(param) > where(customer_number: param).first! > end > end > > — Paul > > > On 04/04/2013, at 10:54 AM, Rich Buggy <[email protected]> wrote: > > > Thanks to everyone who replied. > > > > @Ben: your approach sounds like what I already have. There is an > invoice_number that's manually calculated in addition to the id. What I was > hoping to do is use the invoice_number in the route instead of id. For > example: My existing route is /:tenant/invoices/:id but I would prefer > /:tenant/invoices/:invoice_number. Doing this seems involve fighting the > framework so I was hoping there may have been an easier way with AR > involving changing how the id was calculated. I'll just live with this for > now so I don't slow down development. I can revisit it when I'm further > down the track. > > > > Rich > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/rails-oceania?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Zoombug Pty Ltd www.zoombugmedia.com -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rails-oceania?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
