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
Post a Comment