Shiny happy people coding

Coding with smile

Pretty URL in Merb

| Comments

If like me, you are fan to pretty URL. You know how use it in RubyOnRails. You need define the return of method to_params. Using Merb, I want using same system in Merb. In first, I test modify the return of to_params method. But it's not the way in Merb. The way is simpliest. You need using option :identify in you resource in your route. With this system I can define the methode ticket_permalink in Oupsnow as defin the pretty URL of ticket. After I just need define what I want in this URL. This return string to be allways use in my URL generated to define a ticket. Finally, I need define a method def self.get_by_permalink(ticket_permalink) that I use in place of Ticket.get(id). I can update easily the URL to define my ticket.

But you need to know that all parameter define your ticket are allways the value of :identity option. Even in nested resource. No id and ticket_id. Only ticket_permalink.

Traduction Fran├žaise