Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Tressa S.1
10 years agoNew member | Level 1
How to display the contents of folder on index page when link is clicked in rails?
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:
def index ...
- 10 years ago
For anyone else that needs help, I did get this to work for my situation using rails.
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: http://blog.jobspire.net/dropbox-on-rails-4-0-ajax-using-dropbox-sdk/
To get the directory views to work, I created this bit of code in the controller:
def folder
@dropbox = current_user.dropbox_session if current_user.dropbox_session
if current_user.dropbox_session
dbsession = DropboxSession.deserialize(current_user.dropbox_session)
@client = DropboxClient.new(dbsession, DROPBOX_APP_MODE).metadata("#{params[:path]}/#{params[:file]}")
end
endThen I created a view called folder.html.erb. It's an exact copy of the main index.html.erb view.
Then I created a partial called dropbox_path_change where I did have to change the code I listed above to use folder_path instead of dropbox_path_change_path.
Then I added the folder_path route to my routes file and now users can navigate into the folders at any level.
Tressa S.1
10 years agoNew member | Level 1
For anyone else that needs help, I did get this to work for my situation using rails.
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: http://blog.jobspire.net/dropbox-on-rails-4-0-ajax-using-dropbox-sdk/
To get the directory views to work, I created this bit of code in the controller:
def folder
@dropbox = current_user.dropbox_session if current_user.dropbox_session
if current_user.dropbox_session
dbsession = DropboxSession.deserialize(current_user.dropbox_session)
@client = DropboxClient.new(dbsession, DROPBOX_APP_MODE).metadata("#{params[:path]}/#{params[:file]}")
end
end
Then I created a view called folder.html.erb. It's an exact copy of the main index.html.erb view.
Then I created a partial called dropbox_path_change where I did have to change the code I listed above to use folder_path instead of dropbox_path_change_path.
Then I added the folder_path route to my routes file and now users can navigate into the folders at any level.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!