I am new to Ruby on Rails. I'm creating an application that allows user generated content, including photo uploading. I have worked with file uploading in PHP applications, but since I'm new to Ruby and Rails, I was wondering if there is a common technique, plugin, or gem that makes managing file uploads really easy.
You need the Paperclip gem. Watch this awesome video from Ryan Bates over at RailsCasts.com then you'll be ready to rock. http://railscasts.com/episodes/134-paperclip
It's easy!
Related
I have an rails app deployed to Heroku. It has image uploads. After deployed to heroku again, i am unable to see old images that are uploaded.
Is heroku reset images folder when app is re-deployed? Please tell me the reason behind it.
Background
Heroku uses an 'ephemeral file system', which from an application architecture point of view should be considered as read-only - it is discarded as soon as the dyno is stopped or restarted (which, along with other occasions, occurs after each push), and is also not shared between multiple dynos.
This is fine for executing code from, as most application data is stored in a database that is independent of the dynos. However, for file uploads this presents a problem, and so any uploads should not be stored directly in the dyno filesystem.
Solution
The simplest solution is to use something like Amazon S3 as your file upload storage solution, and, if using a gem like Paperclip, this is natively supported within the gem. There is a great overview article in the Heroku Dev Center about using S3 and Heroku (https://devcenter.heroku.com/articles/s3), which leads into an article contributed by Thoughtbot (the developers of Paperclip) on implemenation specifics within a Rails app (https://devcenter.heroku.com/articles/paperclip-s3)
I have worked with faye on node before, but now want to add it to a rails app. I've found plenty of quick integration guides and have it up and running, but my current implementation is pretty hacky. I've been unable to find any longer tutorials or examples including a good convention for the server to subscribe to the faye channels, interact with the rails models, and publish responses. Does anyone know of good resources?
The below links can be useful for you,
http://railscasts.com/episodes/260-messaging-with-faye?view=asciicast
First one exhibits the simple instant message application in Rails with the help of faye.
I found the How to Use Faye as a Real-Time Push Server in Rails tutorial to be a good start:
We’re going build a simple chat service. Now, Ryan Bates covered this on Railscast #260, however, we’re going to take a slightly different approach in this tutorial. First, we’ll create a chat service where users enter a public room, and everyone can chat with each other publicly. The second functionality we’ll be adding is private messages. Additionally, we’ll integrate some security to our implementation using Ryan Bate’s private_pub gem.
In about one hour you get a hands-on experience and understanding of Faye, both as a server and as a client. By the end of it you have a very basic chat; and not only that, your chat is also secure via private_pub.
Faye has moved towards rack compatibility, so using a config.ru file and booting with the command rackup is advised (the listen method will not work on the latest version of faye).
Booting Faye with rails isn't encouraged, because FAYE isn't compatible with development middleware in rails, meaning you will always need to run in production mode.
A minimalistic barebones example project was written, which deploys cleanly to heroku as observed live at faye-rails-example.herokuapp.com.
I am adding functionailty to our website so users can upload pictures to our site and I'm going to use amazon s3 for that.
I came across these three gems:
aws-sdk (https://github.com/amazonwebservices/aws-sdk-for-ruby)
right_aws (https://github.com/rightscale/right_aws)
aws-s3
I read that aws-s3 is not as good as right_aws, and doesn't get update as often. But I can't find anywhere that compares right_aws vs aws-sdk and looks like they are both directly written by amazon.
Also I came across an article that was using paperclip and aws-s3 together, do I need to use paperclip with any of those as well?
any ideas?
Definitely use The official AWS SDK for Ruby (docs). Some gems unfortunately depend on fog, which was written before amazon's version came out. I would only use fog if another gem, such as carrierwave, dragged it in.
I am working in a project where I should integrate webcam to my web application and record the video and save it in local file system.Can any1 tell me which free api or plugin or gem I can use for this?
Thanks in Advance!!!
This might be late for the party, but I created a gem that will allow you to capture photos easily:
Headshot - Easy web cam integration for Ruby on Rails.
http://headshot.hypermediasoft.com/
This might be helpful for you
http://lassebunk.dk/2011/02/19/paperclip-jpegcam-webcam-rails3/
I have a very simple Ruby on Rails project that has an ActiveRecords model with some validations, and a pretty basic view and controller that allows basic add/update/delete/search interaction with database.
I'd like for the professor to be able to use the website, assuming he has Rails3 installed.
What would be a good way to submit this project? Specifically: what files and folders should I include, and what files should I exclude? What about directions for the professor? Anything else that I should include?
I think that a good idea will be to develop your project locally and then uploaded to a github repository for the professor to see your code. If you want a free, easy and EXCELLENT place to host your application try heroku, it is a cloud application platform where you can host your project(if you use a shared database < 5MB you will be able to do it with the free plan). I recommend you to include a README file a the root of your app where you add all your directions.