I am a beginner with Ruby on Rails but am trying to create my own application.
I've added users and a few models but am stuck on something.... I am trying to create a model called 'JOBS' with the following items:
Im not sure how to get the file upload form in there...
If someone can point me in the right direction it would be greatly appreciated.
The docs are excellent, and show you how to create an upload form. CarrierWave is what many Rails professionals choose to use because it offers many conveniences, ways to upload multiple files at once, multiple backend storage systems such as Amazon S3, etc.
For example, you could write a job that has a title and image like this:
class ImageUploader < CarrierWave::Uploader::Base
storage :file
end
class Job < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
Alternatively, if you're interested in learning how to do it in Rails without any gem, then read the 的
For example, you could write a form that has a job title and image like this:
<%= form_for @job do |f| %>
<%= f.text_field :title %>
<%= f.file_field :image %>
<% end %>
If you are uploading to Amazon S3 i found that using the Paperclip gem was pretty straight forward.
Here is a walkthrough from Heroku: https://devcenter.heroku.com/articles/paperclip-s3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.