ruby - Create Array url_options for rails -


my rails application default url post _http://0.0.0.0:3000/posts/7, how can display url _http://0.0.0.0:3000/posts/cer4235235ft5435rerjk343f numbers , text.

create column in database, update alpha numeric string, , use column querying.

eg:

add column permalink posts table

class post < activerecord::base   before_create :create_permalink    def create_permalink     self.permalink = securerandom.hex   end   .. 

change links use string

<%= link_to post.title, post_path(:id => post.permalink) %> 

modify controller

def show   @post = post.where(:permalink => params[:id]).first end 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -