<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to display the contents of folder on index page when link is clicked in rails? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-the-contents-of-folder-on-index-page-when-link-is/m-p/140994#M4397</link>
    <description>&lt;P&gt;I have code in rails 4.2.3 where on the index page of the dropbox connect feature, it creates a list of the files in the user's root dropbox directory once logged in. This is the code:&lt;/P&gt;
&lt;P&gt;def index&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/2"&gt;@druidbox&lt;/a&gt; = current_user.dropbox_session if current_user.dropbox_session&lt;BR /&gt; # find the current user's dropbox_session from the database&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if current_user.dropbox_session&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dbsession = DropboxSession.deserialize(current_user.dropbox_session)&lt;BR /&gt; # create the dropbox client object&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; @client = DropboxClient.new(dbsession, DROPBOX_APP_MODE).metadata('/')&lt;BR /&gt;&amp;nbsp; &amp;nbsp;end&lt;BR /&gt; end&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this list created, you can see and download any files at the root level. You can see any directory at the root level. The directory is even linked but when clicked, it refreshes the page but doesn't change the contents of the view. &amp;nbsp;This is the code I have in the index view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;tbody&amp;gt;&lt;BR /&gt; &amp;lt;% @client["contents"].each do |key, value| %&amp;gt;&lt;BR /&gt; &amp;lt;tr&amp;gt;&lt;BR /&gt; &amp;lt;td&amp;gt;&lt;BR /&gt; &amp;lt;% if (key["is_dir"]) %&amp;gt;&lt;BR /&gt; &amp;lt;%= "&amp;lt;div class='glyphicon glyphicon-folder-open'&amp;gt;&amp;lt;/div&amp;gt; ".html_safe %&amp;gt; &amp;amp;nbsp;&lt;BR /&gt; &amp;lt;%= link_to key["path"][1..-1], dropbox_path_change_path(path: key["path"]) %&amp;gt; &amp;amp;nbsp; &lt;BR /&gt; &amp;lt;%else %&amp;gt;&lt;BR /&gt; &amp;lt;%= key["path"][1..-1]%&amp;gt; &amp;amp;nbsp; &lt;BR /&gt; &amp;lt;%= link_to "[#{key["size"]} &amp;lt;div class='glyphicon glyphicon-cloud-download'&amp;gt;&amp;lt;/div&amp;gt;]".html_safe, dropbox_download_path(path: key["path"]), :target =&amp;gt; "_blank" %&amp;gt; &lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;/td&amp;gt;&lt;BR /&gt; &amp;lt;/tr&amp;gt;&lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;/tbody&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dropbox_path_change_path is just a partial that reloads the index. I was thinking that when someone clicks on the link for a folder, it would reload the index but list the contents of the directory the link goes to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I display the contents of the folder on the index page when the link is clicked?&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:38:57 GMT</pubDate>
    <dc:creator>Tressa S.1</dc:creator>
    <dc:date>2019-05-29T09:38:57Z</dc:date>
    <item>
      <title>How to display the contents of folder on index page when link is clicked in rails?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-the-contents-of-folder-on-index-page-when-link-is/m-p/140994#M4397</link>
      <description>&lt;P&gt;I have code in rails 4.2.3 where on the index page of the dropbox connect feature, it creates a list of the files in the user's root dropbox directory once logged in. This is the code:&lt;/P&gt;
&lt;P&gt;def index&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/2"&gt;@druidbox&lt;/a&gt; = current_user.dropbox_session if current_user.dropbox_session&lt;BR /&gt; # find the current user's dropbox_session from the database&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if current_user.dropbox_session&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dbsession = DropboxSession.deserialize(current_user.dropbox_session)&lt;BR /&gt; # create the dropbox client object&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; @client = DropboxClient.new(dbsession, DROPBOX_APP_MODE).metadata('/')&lt;BR /&gt;&amp;nbsp; &amp;nbsp;end&lt;BR /&gt; end&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this list created, you can see and download any files at the root level. You can see any directory at the root level. The directory is even linked but when clicked, it refreshes the page but doesn't change the contents of the view. &amp;nbsp;This is the code I have in the index view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;tbody&amp;gt;&lt;BR /&gt; &amp;lt;% @client["contents"].each do |key, value| %&amp;gt;&lt;BR /&gt; &amp;lt;tr&amp;gt;&lt;BR /&gt; &amp;lt;td&amp;gt;&lt;BR /&gt; &amp;lt;% if (key["is_dir"]) %&amp;gt;&lt;BR /&gt; &amp;lt;%= "&amp;lt;div class='glyphicon glyphicon-folder-open'&amp;gt;&amp;lt;/div&amp;gt; ".html_safe %&amp;gt; &amp;amp;nbsp;&lt;BR /&gt; &amp;lt;%= link_to key["path"][1..-1], dropbox_path_change_path(path: key["path"]) %&amp;gt; &amp;amp;nbsp; &lt;BR /&gt; &amp;lt;%else %&amp;gt;&lt;BR /&gt; &amp;lt;%= key["path"][1..-1]%&amp;gt; &amp;amp;nbsp; &lt;BR /&gt; &amp;lt;%= link_to "[#{key["size"]} &amp;lt;div class='glyphicon glyphicon-cloud-download'&amp;gt;&amp;lt;/div&amp;gt;]".html_safe, dropbox_download_path(path: key["path"]), :target =&amp;gt; "_blank" %&amp;gt; &lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;/td&amp;gt;&lt;BR /&gt; &amp;lt;/tr&amp;gt;&lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;%end%&amp;gt;&lt;BR /&gt; &amp;lt;/tbody&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dropbox_path_change_path is just a partial that reloads the index. I was thinking that when someone clicks on the link for a folder, it would reload the index but list the contents of the directory the link goes to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I display the contents of the folder on the index page when the link is clicked?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:38:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-the-contents-of-folder-on-index-page-when-link-is/m-p/140994#M4397</guid>
      <dc:creator>Tressa S.1</dc:creator>
      <dc:date>2019-05-29T09:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the contents of folder on index page when link is clicked in rails?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-the-contents-of-folder-on-index-page-when-link-is/m-p/140995#M4398</link>
      <description>&lt;P&gt;For anyone else that needs help, I did get this to work for my situation using rails.&lt;/P&gt;
&lt;P&gt;First off, I followed this tutorial which he admitted wasn't tested so I did have to make changes to get it to work and this was one of them:&amp;nbsp;&lt;A href="http://blog.jobspire.net/dropbox-on-rails-4-0-ajax-using-dropbox-sdk/" rel="nofollow noreferrer"&gt;http://blog.jobspire.net/dropbox-on-rails-4-0-ajax-using-dropbox-sdk/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;To get the directory views to work, I created this bit of code in the controller:&lt;/P&gt;
&lt;P&gt;def folder&lt;BR /&gt; @dropbox = current_user.dropbox_session if current_user.dropbox_session&lt;BR /&gt; if current_user.dropbox_session&lt;BR /&gt; dbsession = DropboxSession.deserialize(current_user.dropbox_session)&lt;BR /&gt; @client = DropboxClient.new(dbsession, DROPBOX_APP_MODE).metadata("#{params[:path]}/#{params[:file]}")&lt;BR /&gt; end&lt;BR /&gt;end&lt;/P&gt;
&lt;P&gt;Then I created a view called folder.html.erb. It's an exact copy of the main index.html.erb view. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I created a partial called&amp;nbsp;dropbox_path_change where&amp;nbsp;I did have to change the code I listed above to use folder_path instead of&amp;nbsp;dropbox_path_change_path.&lt;/P&gt;
&lt;P&gt;Then I added the folder_path route to my routes file and now users can navigate into the folders at any level.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 10:47:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-the-contents-of-folder-on-index-page-when-link-is/m-p/140995#M4398</guid>
      <dc:creator>Tressa S.1</dc:creator>
      <dc:date>2015-11-01T10:47:16Z</dc:date>
    </item>
  </channel>
</rss>

