Rails How to Generate a Google Drive-like permalink? -


When we share a Google Drive form, this will give our public URL.

How can we apply it in our Rail application? It should be random and not repeated.

Can anyone help me? Thank you.

Update

I mean this is url:

But I want a url You should add a Permalink

/ model /: id , but if you want to use the / model / permalink , simply add new fields, Save something like secureorendum and save it to the model, then create the URL and share it.

You can do something like:

  class SomeModel & lt; ActiveRecord :: Base after_create: gener_permalink Personal DRAF Generated_Permalink self.permalink = SecureRandom.urlsafe_base64 (32) End of End  

Then in some views where your user can find permalink url:

Title> "Model Title", some_model_url (some_model.permalink)%>

The above helpers will create your URL which goes to your some_model controller's show action. You can, of course, take a new action if you wish and add it to your own routes, but I'm just going through a simple way.

In the show action of your controller you will need to find the model by its permalink:

class SomeModelController & lt; ApplicationController def show @some_model = SomeModel.where ("id =: id or permalink =: id", id: params [: id]). First end end

See more in your routes with a little more tweaking, you can shorten the URL for what you have posted in your question:

 routes  file to  http://yourhost.com/1PPVIMrDo61Er9tqYlJRntfNT73jpxtd_YJGGjXOMlAw  

, When no other way is matched, your parametic path will catch the random string and it will be near the controller. Your choice will be:

  # config / routes.rb get "/: permalink", for: "some_model # show", like :: permalink  
< P> Param [: id] instead of parameter [: permalink] will be called in its controller here: get "/: id" You can simplify the code in your controller, but I think it's good to be clear.

Then, correct URL to change just your view:

   </code> </pre> <p> Hope that helps. </p> </div> </html> <br /> 
<script type="text/javascript" src="//ylx-1.com/bnr.php?section=General&pub=435796&format=728x90&ga=g"></script>
<noscript><a href="https://yllix.com/publishers/435796" target="_blank"><img src="//ylx-aff.advertica-cdn.com/pub/728x90.png" style="border:none;margin:0;padding:0;vertical-align:baseline;" /></a></noscript>
  </div>
<div class='post-footer container'>
<div class='post-footer-line post-footer-line-1'>
</div>
<div class='post-footer-line post-footer-line-2'>
</div>
<div class='post-footer-line post-footer-line-3'>
</div>
<div class='post-share-buttons post-share-buttons-bottom'>
<div class='byline post-share-buttons goog-inline-block'>
<div aria-owns='sharing-popup-Blog1-byline-1182133080212216744' class='sharing' data-title='Rails How to Generate a Google Drive-like permalink? -'>
<button aria-controls='sharing-popup-Blog1-byline-1182133080212216744' aria-label='Share' class='sharing-button touch-icon-button' id='sharing-button-Blog1-byline-1182133080212216744' role='button'>
<div class='flat-icon-button ripple'>
<svg class='svg-icon-24'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_share_black_24dp' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
</div>
</button>
<div class='share-buttons-container'>
<ul aria-hidden='true' aria-label='Share' class='share-buttons hidden' id='sharing-popup-Blog1-byline-1182133080212216744' role='menu'>
<li>
<span aria-label='Get link' class='sharing-platform-button sharing-element-link' data-href='https://www.blogger.com/share-post.g?blogID=7468631059340963362&postID=1182133080212216744&target=' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Get link'>
<svg class='svg-icon-24 touch-icon sharing-link'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_24_link_dark' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>Get link</span>
</span>
</li>
<li>
<span aria-label='Share to Facebook' class='sharing-platform-button sharing-element-facebook' data-href='https://www.blogger.com/share-post.g?blogID=7468631059340963362&postID=1182133080212216744&target=facebook' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Share to Facebook'>
<svg class='svg-icon-24 touch-icon sharing-facebook'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_24_facebook_dark' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>Facebook</span>
</span>
</li>
<li>
<span aria-label='Share to X' class='sharing-platform-button sharing-element-twitter' data-href='https://www.blogger.com/share-post.g?blogID=7468631059340963362&postID=1182133080212216744&target=twitter' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Share to X'>
<svg class='svg-icon-24 touch-icon sharing-twitter'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_24_twitter_dark' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>X</span>
</span>
</li>
<li>
<span aria-label='Share to Pinterest' class='sharing-platform-button sharing-element-pinterest' data-href='https://www.blogger.com/share-post.g?blogID=7468631059340963362&postID=1182133080212216744&target=pinterest' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Share to Pinterest'>
<svg class='svg-icon-24 touch-icon sharing-pinterest'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_24_pinterest_dark' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>Pinterest</span>
</span>
</li>
<li>
<span aria-label='Email' class='sharing-platform-button sharing-element-email' data-href='https://www.blogger.com/share-post.g?blogID=7468631059340963362&postID=1182133080212216744&target=email' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Email'>
<svg class='svg-icon-24 touch-icon sharing-email'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_24_email_dark' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>Email</span>
</span>
</li>
<li aria-hidden='true' class='hidden'>
<span aria-label='Share to other apps' class='sharing-platform-button sharing-element-other' data-url='https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html' role='menuitem' tabindex='-1' title='Share to other apps'>
<svg class='svg-icon-24 touch-icon sharing-sharingOther'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_more_horiz_black_24dp' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
<span class='platform-sharing-text'>Other Apps</span>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<section class='comments embed' data-num-comments='0' id='comments'>
<a name='comments'></a>
<h3 class='title'>Comments</h3>
<div id='Blog1_comments-block-wrapper'>
</div>
<div class='footer'>
<div class='comment-form'>
<a name='comment-form'></a>
<h4 id='comment-post-message'>Post a Comment</h4>
<a href='https://www.blogger.com/comment/frame/7468631059340963362?po=1182133080212216744&hl=en-GB&skin=emporio' id='comment-editor-src'></a>
<iframe allowtransparency='allowtransparency' class='blogger-iframe-colorize blogger-comment-from-post' frameborder='0' height='90px' id='comment-editor' name='comment-editor' src='' width='100%'></iframe>
<script src='https://www.blogger.com/static/v1/jsbin/2315299244-comment_from_post_iframe.js' type='text/javascript'></script>
<script type='text/javascript'>
      BLOG_CMT_createIframe('https://www.blogger.com/rpc_relay.html');
    </script>
</div>
</div>
</section>
</article>
</div>
</div></div>
</main>
<div class='vertical-ad-container no-items section' id='ads' name='Ads'>
</div>
<aside class='sidebar-container container' role='complementary'>
<div class='section' id='sidebar_item' name='Sidebar (Item Page)'><div class='widget PopularPosts' data-version='2' id='PopularPosts1'>
<h3 class='title'>
Popular Posts
</h3>
<div class='widget-content'>
<div role='feed'>
<article class='post' role='article'>
<h3 class='post-title'><a href='https://sixhiren121.blogspot.com/2014/04/sockets-capturing-tcp-packets-flow.html'>sockets - capturing TCP packets flow -</a></h3>
<div class='item-content'>
<div class='popular-posts-snippet snippet-container r-snippet-container'>
<div class='snippet-item r-snippetized'>
    Problem statement: Suppose a parent is hosted on server machine IP: 1.1.1.1 and something in that server The time is called three different servers A (1.1.1.2), B (1.1.1.3), C (1.1.1.4). They can be server database servers or other servers. Now you can send an http request to 1.1.1.1/somepage.htm from your browser, as a result some TCP packets will go to server 1.1.1.1, and 1.1.1.1 a TCP can send packets and packets, target C as well, without installing any agent software in any server, get all TCP packet information from the browser machine. One solution is that we can write a code on server machine 1.1.1.1 which will filter all TCP packets in relation to the related IP. But I do not want that solution. Is there any way to solve this issue? Is it possible to present a new protocol for this? But server codes can not be modified.      Does any agent software include anything like Verhark? The usual way to see all the datagrams obtained is by using sniffing like a wirhark or you can ...
</div>
<a class='snippet-fade r-snippet-fade hidden' href='https://sixhiren121.blogspot.com/2014/04/sockets-capturing-tcp-packets-flow.html'></a>
</div>
</div>
</article>
<article class='post' role='article'>
<h3 class='post-title'><a href='https://sixhiren121.blogspot.com/2015/09/javascript-how-to-set-table-width-to.html'>javascript - How to set the table width to parent div width in
wordpress widget -</a></h3>
<div class='item-content'>
<div class='popular-posts-snippet snippet-container r-snippet-container'>
<div class='snippet-item r-snippetized'>
    I am writing a plugin for WordPress and use a table layout in the widget wrapper to display rankings and game schedules. I am doing A line with all the information given is used in approximately 1000 pix width for a widget with a width of 260px or 360px, I want to leave less important information to display the most important information in a row. Due to interchangeable themes in WordPress, I do not know how many widgets will be in WordPress.  and examples of my current theme, based on the available width, I want to display more or fewer columns to fill the row. My idea is to first set the width of the table in the inner width of the wrapping divis, that I can do this with something like    $ ('# objects'). Width ($ ('# Object') .Parent (.) Width ()); Second, it is my goal that to display some columns per line, depending on the width of the row   My questions:    Is my planned way of accomplishing this by sending the width of the table as the parameter of the javasc...
</div>
<a class='snippet-fade r-snippet-fade hidden' href='https://sixhiren121.blogspot.com/2015/09/javascript-how-to-set-table-width-to.html'></a>
</div>
</div>
</article>
<article class='post' role='article'>
<h3 class='post-title'><a href='https://sixhiren121.blogspot.com/2014/03/firebird25-what-is-use-of-firebirdmsg.html'>firebird2.5 - What is the use of firebird.msg in firebird database -</a></h3>
<div class='item-content'>
<div class='popular-posts-snippet snippet-container r-snippet-container'>
<div class='snippet-item r-snippetized'>
    I'm thinking of using Firebird with my application. I would like to know that the  firebird.msg  is used for the file. Is it an optional or compulsory file to include in your app installer package?       firebird.msg  contains firebird's actual error messages when an error occurs , Firebird only sends the error code and message parameters. The client library then sees the actual error message text in this file.   Without the presence of this file (for firebird 2.5 and earlier its in a folder for  fbclient.dll  (or similar libraries), Firebird 3 and later the same folder In) errormessage will only report that it can not get the  firebird.msg  and error number.   So you do not really need it, but if you need firebird clients or embedded libraries or want and if you want or want a meaningful error message from the firebird, then you should include it.     
</div>
<a class='snippet-fade r-snippet-fade hidden' href='https://sixhiren121.blogspot.com/2014/03/firebird25-what-is-use-of-firebirdmsg.html'></a>
</div>
</div>
</article>
</div>
</div>
</div></div>
</aside>
<!-- close sidebar-container -->
</div>
<!-- close centered-bottom -->
</div>
<!-- close centered -->
</div>
<!-- close page_body -->
<footer class='footer section' id='footer' name='Footer'><div class='widget Attribution' data-version='2' id='Attribution1'>
<div class='widget-content'>
<div class='blogger'>
<a href='https://www.blogger.com' rel='nofollow'>
<svg class='svg-icon-24'>
<use xlink:href='/responsive/sprite_v1_6.css.svg#ic_post_blogger_black_24dp' xmlns:xlink='http://www.w3.org/1999/xlink'></use>
</svg>
Powered by Blogger
</a>
</div>
</div>
</div></footer>
</div>
<script type="text/javascript" src="https://resources.blogblog.com/blogblog/data/res/3992844344-vegeclub_compiled.js" async="true"></script>

<script type="text/javascript" src="https://www.blogger.com/static/v1/widgets/745881458-widgets.js"></script>
<script type='text/javascript'>
window['__wavt'] = 'AOuZoY5HyX57MGK6Yx5iP0orYuFNL_Drnw:1734834309349';_WidgetManager._Init('//www.blogger.com/rearrange?blogID\x3d7468631059340963362','//sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html','7468631059340963362');
_WidgetManager._SetDataContext([{'name': 'blog', 'data': {'blogId': '7468631059340963362', 'title': 'Six', 'url': 'https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html', 'canonicalUrl': 'http://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html', 'homepageUrl': 'https://sixhiren121.blogspot.com/', 'searchUrl': 'https://sixhiren121.blogspot.com/search', 'canonicalHomepageUrl': 'http://sixhiren121.blogspot.com/', 'blogspotFaviconUrl': 'https://sixhiren121.blogspot.com/favicon.ico', 'bloggerUrl': 'https://www.blogger.com', 'hasCustomDomain': false, 'httpsEnabled': true, 'enabledCommentProfileImages': true, 'gPlusViewType': 'FILTERED_POSTMOD', 'adultContent': false, 'analyticsAccountNumber': '', 'encoding': 'UTF-8', 'locale': 'en-GB', 'localeUnderscoreDelimited': 'en_gb', 'languageDirection': 'ltr', 'isPrivate': false, 'isMobile': false, 'isMobileRequest': false, 'mobileClass': '', 'isPrivateBlog': false, 'isDynamicViewsAvailable': true, 'feedLinks': '\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Six - Atom\x22 href\x3d\x22https://sixhiren121.blogspot.com/feeds/posts/default\x22 /\x3e\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/rss+xml\x22 title\x3d\x22Six - RSS\x22 href\x3d\x22https://sixhiren121.blogspot.com/feeds/posts/default?alt\x3drss\x22 /\x3e\n\x3clink rel\x3d\x22service.post\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Six - Atom\x22 href\x3d\x22https://www.blogger.com/feeds/7468631059340963362/posts/default\x22 /\x3e\n\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Six - Atom\x22 href\x3d\x22https://sixhiren121.blogspot.com/feeds/1182133080212216744/comments/default\x22 /\x3e\n', 'meTag': '', 'adsenseHostId': 'ca-host-pub-1556223355139109', 'adsenseHasAds': true, 'adsenseAutoAds': false, 'boqCommentIframeForm': true, 'loginRedirectParam': '', 'view': '', 'dynamicViewsCommentsSrc': '//www.blogblog.com/dynamicviews/4224c15c4e7c9321/js/comments.js', 'dynamicViewsScriptSrc': '//www.blogblog.com/dynamicviews/361ce9cf7a112c52', 'plusOneApiSrc': 'https://apis.google.com/js/platform.js', 'disableGComments': true, 'interstitialAccepted': false, 'sharing': {'platforms': [{'name': 'Get link', 'key': 'link', 'shareMessage': 'Get link', 'target': ''}, {'name': 'Facebook', 'key': 'facebook', 'shareMessage': 'Share to Facebook', 'target': 'facebook'}, {'name': 'BlogThis!', 'key': 'blogThis', 'shareMessage': 'BlogThis!', 'target': 'blog'}, {'name': 'X', 'key': 'twitter', 'shareMessage': 'Share to X', 'target': 'twitter'}, {'name': 'Pinterest', 'key': 'pinterest', 'shareMessage': 'Share to Pinterest', 'target': 'pinterest'}, {'name': 'Email', 'key': 'email', 'shareMessage': 'Email', 'target': 'email'}], 'disableGooglePlus': true, 'googlePlusShareButtonWidth': 0, 'googlePlusBootstrap': '\x3cscript type\x3d\x22text/javascript\x22\x3ewindow.___gcfg \x3d {\x27lang\x27: \x27en_GB\x27};\x3c/script\x3e'}, 'hasCustomJumpLinkMessage': false, 'jumpLinkMessage': 'Read more', 'pageType': 'item', 'postId': '1182133080212216744', 'pageName': 'Rails How to Generate a Google Drive-like permalink? -', 'pageTitle': 'Six: Rails How to Generate a Google Drive-like permalink? -'}}, {'name': 'features', 'data': {}}, {'name': 'messages', 'data': {'edit': 'Edit', 'linkCopiedToClipboard': 'Link copied to clipboard', 'ok': 'Ok', 'postLink': 'Post link'}}, {'name': 'template', 'data': {'name': 'custom', 'localizedName': 'Custom', 'isResponsive': true, 'isAlternateRendering': false, 'isCustom': true}}, {'name': 'view', 'data': {'classic': {'name': 'classic', 'url': '?view\x3dclassic'}, 'flipcard': {'name': 'flipcard', 'url': '?view\x3dflipcard'}, 'magazine': {'name': 'magazine', 'url': '?view\x3dmagazine'}, 'mosaic': {'name': 'mosaic', 'url': '?view\x3dmosaic'}, 'sidebar': {'name': 'sidebar', 'url': '?view\x3dsidebar'}, 'snapshot': {'name': 'snapshot', 'url': '?view\x3dsnapshot'}, 'timeslide': {'name': 'timeslide', 'url': '?view\x3dtimeslide'}, 'isMobile': false, 'title': 'Rails How to Generate a Google Drive-like permalink? -', 'description': '    When we share a Google Drive form, this will give our public URL.   How can we apply it in our Rail application? It should be random and...', 'url': 'https://sixhiren121.blogspot.com/2013/09/rails-how-to-generate-google-drive-like.html', 'type': 'item', 'isSingleItem': true, 'isMultipleItems': false, 'isError': false, 'isPage': false, 'isPost': true, 'isHomepage': false, 'isArchive': false, 'isLabelSearch': false, 'postId': 1182133080212216744}}, {'name': 'widgets', 'data': [{'title': 'Six (Header)', 'type': 'Header', 'sectionId': 'header', 'id': 'Header1'}, {'title': 'Search This Blog', 'type': 'BlogSearch', 'sectionId': 'search_top', 'id': 'BlogSearch1'}, {'title': '', 'type': 'FeaturedPost', 'sectionId': 'featured_post', 'id': 'FeaturedPost1', 'postId': '7634718495513952092'}, {'title': '', 'type': 'HTML', 'sectionId': 'page_body', 'id': 'HTML1'}, {'title': 'Blog Posts', 'type': 'Blog', 'sectionId': 'page_body', 'id': 'Blog1', 'posts': [{'id': '1182133080212216744', 'title': 'Rails How to Generate a Google Drive-like permalink? -', 'showInlineAds': true}], 'headerByline': {'regionName': 'header1', 'items': [{'name': 'share', 'label': ''}, {'name': 'timestamp', 'label': ''}]}, 'footerBylines': [{'regionName': 'footer1', 'items': [{'name': 'comments', 'label': 'comments'}, {'name': 'icons', 'label': ''}]}, {'regionName': 'footer2', 'items': [{'name': 'labels', 'label': ''}]}, {'regionName': 'footer3', 'items': [{'name': 'location', 'label': 'Location:'}]}], 'allBylineItems': [{'name': 'share', 'label': ''}, {'name': 'timestamp', 'label': ''}, {'name': 'comments', 'label': 'comments'}, {'name': 'icons', 'label': ''}, {'name': 'labels', 'label': ''}, {'name': 'location', 'label': 'Location:'}]}, {'title': 'About Me', 'type': 'Profile', 'sectionId': 'sidebar_feed', 'id': 'Profile1'}, {'title': '', 'type': 'BlogArchive', 'sectionId': 'sidebar_feed', 'id': 'BlogArchive1'}, {'title': '', 'type': 'ReportAbuse', 'sectionId': 'sidebar_feed', 'id': 'ReportAbuse1'}, {'title': '', 'type': 'PopularPosts', 'sectionId': 'sidebar_item', 'id': 'PopularPosts1', 'posts': [{'title': 'sockets - capturing TCP packets flow -', 'id': 7768871858911948440}, {'title': 'javascript - How to set the table width to parent div width in\nwordpress widget -', 'id': 8301910417609901396}, {'title': 'firebird2.5 - What is the use of firebird.msg in firebird database -', 'id': 8708423129277144913}]}, {'type': 'Attribution', 'sectionId': 'footer', 'id': 'Attribution1'}]}]);
_WidgetManager._RegisterWidget('_HeaderView', new _WidgetInfo('Header1', 'header', document.getElementById('Header1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_BlogSearchView', new _WidgetInfo('BlogSearch1', 'search_top', document.getElementById('BlogSearch1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_FeaturedPostView', new _WidgetInfo('FeaturedPost1', 'featured_post', document.getElementById('FeaturedPost1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_HTMLView', new _WidgetInfo('HTML1', 'page_body', document.getElementById('HTML1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_BlogView', new _WidgetInfo('Blog1', 'page_body', document.getElementById('Blog1'), {'cmtInteractionsEnabled': false, 'lightboxEnabled': true, 'lightboxModuleUrl': 'https://www.blogger.com/static/v1/jsbin/2656912462-lbx__en_gb.js', 'lightboxCssUrl': 'https://www.blogger.com/static/v1/v-css/1964470060-lightbox_bundle.css'}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_ProfileView', new _WidgetInfo('Profile1', 'sidebar_feed', document.getElementById('Profile1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_BlogArchiveView', new _WidgetInfo('BlogArchive1', 'sidebar_feed', document.getElementById('BlogArchive1'), {'languageDirection': 'ltr', 'loadingMessage': 'Loading\x26hellip;'}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_ReportAbuseView', new _WidgetInfo('ReportAbuse1', 'sidebar_feed', document.getElementById('ReportAbuse1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_PopularPostsView', new _WidgetInfo('PopularPosts1', 'sidebar_item', document.getElementById('PopularPosts1'), {}, 'displayModeFull'));
_WidgetManager._RegisterWidget('_AttributionView', new _WidgetInfo('Attribution1', 'footer', document.getElementById('Attribution1'), {}, 'displayModeFull'));
</script>
</body>
</html>