How do I browse folder using simple_form? - ruby-on-rails

I want to add a file/folder browsing button in my rails application using simple_form gem.
How do I do it? In simple_form documentation it is not mentioned.
Edit: File browse is mentioned in the documentation. But how to browse folders is not mentioned. Currently the only way I think possible is extract the folder from the file path. But what if there are no files present in the folder?

You would do:
f.input :somename, as: :file

Related

Rails file upload: upload a folder

I work on Rails project and client asked if I can add 'upload a folder' feature to simple file upload system that we have now. Currently it attaches files to model and then displays them on a page for download. Pretty basic.
But I can't figure out how can I handle folder uploads, with every folder having it's own content. Is there any pre-made gems that can help accomplish that?
We use Paperclip at the moment, but I don't mind migrating to Carrerwave or some other gem that would
UPDATE I see that I was unclear about my needs. I need an upload system that could handle folders. Something like this.
In Dropbox I am able to upload both files and folders. How can I make my uploaders accept folders and then display them alongside regular attached files?
you can solve it by using the interpolation of paperclip where you can create or naming the folder dynamically for the same you need to do like below
specify the path into model which you wanted always
:path => ":folder/:id_:filename"
and specify the private method in same model or using globally specify in initializer
Paperclip::interpolates :folder do |attachment, style|
attachment.instance.name
end

Upload Files to a particular Folder in Ruby On Rails 4

I am using working on a particular module in Ruby on Rails, where I want to upload files to a particular folder. If it's possible, would you please share some examples which may help me achieve this functionality?
As #dharam mentioned. you can use paperclip. The working example you can find here
demo
If you want to specify folder path where the attachments should move. you need to write this in your model
has_attached_file :attachment, :path => ":rails_root/attachments/:id/:style/:basename.:extension"
After this all your attachments will be seen in attachments folder in your Application root
paperclip gem supports multiple storage options, including file storage.
Refer to FileSystem for more info.
Other gem you can look into is carrierwave

Ruby Rails - Cant locate routes.rb to add page to site

I am currently working on a project where the majority if the site structure is already in place. I am trying to add a new section to it but am having difficulty getting links to work.
I replicated what another page had however in tutorials I am seeing reference to a routes.rb file which specifies how links work. The problem is i cannot locate the routes.rb file. Is there anything I am missing or is routes.rb specific to a certain version and I am using a different version. Any help would be much appreciated.
I think your routes file was deleted. You can check git status. You will be find deleted file there. Rollback that change or create new file routes.rb in config/ folder.
If the app is a standard Rails app, you should be able to find routes.rb in the app's config/ folder.
How about just using your editor to do a file search and locate the file?
For Sublime Text, cmd + p for MAC will suffice.

How to offer files in ruby on rails with authentification?

My problem is, I upload files to my server, and atm the uploaded files are located under an asset directory, but I don't want all users grant the access to the files, but if the file is located under an asset directory, all users can download them etc.
But if a user want to alter his file, then he should get access to them f.e. with js (think that i use js as an editor).
Can someone help me?
I hope you use Paperclip gem. Read this post about protected file download: http://thewebfellas.com/blog/2009/8/29/protecting-your-paperclip-downloads

Ruby on Rails - Unable to add "".jpg" file

I am new to the Ruby on Rails.
I want to add ".jpg" file under the /Public/Images folder.
When I navigate to the add New page, I don't see the Picture Format in the menu.
If you are working with rails3.1 or next of that, there is an app/assets/images folder in your application directory. And there is a default image rails.png available.
Add any images over there and use them as follows:
<%= image_tag "/assets/rails.png"%>

Resources