carrierwave

How can I create multiple objects in a single form in Rails 3.1?

 ̄綄美尐妖づ 提交于 2019-12-06 01:30:15
I have a Photo model and I want to set up a form so that a user can create multiple photos from the same form. I've watched the Railscasts #196 and 197 on nested model forms but that is more complex than what I need and deals more with forms containing multiple models, not multiple objects of the same model. Below is my code for a simple form that lets a user attach an image and create a new Photo object. I've experimented with fields_for and tried nesting but it seems overly complicated and I can't get it working. Any ideas on how I could set this form up to allow the user to attach 5 images

Carrierwave with Dropzone JS. Is it possible to use these with nested attributes?

痞子三分冷 提交于 2019-12-06 00:19:52
Currently, I have several forms that work with nested attributes. I found out recently about Dropzone JS, so I wanted to implement it in various forms I'm using. I have two models similar to these: Games class Games < ActiveRecord::base has_many :screenshots, dependent: :destroy accepts_nested_attributes_for :screenshots, allow_destroy: true end Screenshots class Screenshot < ActiveRecord::Base belongs_to :game mount_uploader :ssfile, ScreenshotUploader end Normally, I'd handle it with something like this: new.html.haml - content_for :breadcrumbs do %h3.text-center New Game .col-md-12#content

Using jCrop with cloudinary through rails 4 to crop before creating image

99封情书 提交于 2019-12-05 19:21:01
I've been at this for some time now. I"m using cloudinary to upload photos and am trying to implement a cropping feature using jcrop on a photo create action. After I implemented cloudinary I followed railscasts #182 on Jcrop. I think I'm having problems getting the new cropped parameters (x,y,w,h) back to the uploader before the image is saved. Update: I'm not even getting the values put into the f.text_fields. When I move the cropper around, there should be new values right? Here's a pic of what it looks like with empty fields: Also when I submit the photo, now I'm getting conflicting

AWS buckets and regions

三世轮回 提交于 2019-12-05 18:45:23
The application is using carrierwave in conjunction with the carrierwave-aws gem. It hit snags when migrating rails versions (bumped up to 4.2), ruby versions (2.2.3) and redeployed to the same staging server. The AWS bucket was initially created in the free tier, thus Oregon, us-west-2. However, I have found that all the S3 files have the property which links to eu-west-1 . Admittedly I've been tinkering around and considered using the eu-west-1 region. However I do not recall making any config changes - not even sure it is allowed in the free tier... So yes, I've had to configure my uploads

CarrierWave with ActiveResource

倖福魔咒の 提交于 2019-12-05 18:20:18
Does anyone have any insights into using CarrierWave with an ActiveResource model (in Rails 3)? I've got an ActiveResource model with field for the filename, and I want to save the file to the remote filesystem. I've tried a few things without much success (or conviction that I was doing anything remotely correctly), so I'd appreciate suggestions from anyone who's successfully implemented CarrierWave without using the ORM modules already included in the gem. I'm probably late for this as the original author has moved on, but this question comes up at the top when someone searches for

Need to change the storage “directory” of files in an S3 Bucket (Carrierwave / Fog)

随声附和 提交于 2019-12-05 17:43:47
I am using Carrierwave with 3 separate models to upload photos to S3. I kept the default settings for the uploader, which was to store photos in a root S3 bucket. I then decided to store them in sub-directories according to model name like /avatars, items/, etc. based on the model they were uploaded from... Then, I noticed that files of the same name were being overwritten and when I deleted a model record, the photo wasn't being deleted. I've since changed the store_dir from an uploader-specific setup like this: def store_dir "items" end to a generic one which stores photo under the model ID

how do I add files already stored on s3 to carrierwave backed by same datastore?

偶尔善良 提交于 2019-12-05 12:51:51
I already have files in my s3, which were uploaded via FTP, and I'd just like to attach them to my models, which allow upload via CarrierWave, if I'm using the same bucket to store the files I upload via CarrierWave and the ones I upload via FTP, is there a way to just assign the s3 key for the file to the (new) associated record (via a model) where the file itself is handled via CarrierWave's attachment strategy? Assuming you have the thumbnails already created, and can store the files in the correct directory on S3, you could simply: @user.update_column(:image, "your-image-name.png") This

CarrierWave Error

僤鯓⒐⒋嵵緔 提交于 2019-12-05 12:20:27
I get an error that looks like this: NoMethodError (undefined method `image_will_change!' for #<Bar:0x24ddda0>): app/controllers/bars_controller.rb:43:in `new' app/controllers/bars_controller.rb:43:in `create' After I click submit for a registration. I am using Carrierwave and have followed the steps to using it, but still have an error. CarrierWave doesn't support the attribute_will_change! call, at least I ran into this error a few times. Follow the steps from How to: Detect a new file in a mounted uploader at CarrierWave's wiki which provide similar functionality. 来源: https://stackoverflow

CarrierWave full url for default image

╄→гoц情女王★ 提交于 2019-12-05 10:35:37
I am using CarrierWave for image uploads on a rails-api application which in turn is consumed by a backbone.js client app. I notice that when there is no default image available it returns /assets/default.png . It in turn has to be http://dev-server:3000/assets/default.png . Here are my configuration settings: # config/environments/development.rb CarrierWave.configure do |config| config.asset_host = "http://dev-server:3000" end # Image Uploader .... def default_url "/assets/default.png" end Where am I going wrong? [Edit (updated answer)] Updating my answer to setup asset_host in rails config.

How to upload a file using AngularJs like the traditional way

a 夏天 提交于 2019-12-05 06:27:27
I've been tried this for days. Assuming I have a form like following: <form ng-submit="create()" class="form-horizontal" enctype="multipart/form-data"> <div class="control-group"> <label class="control-label">name : </label> <div class="controls"> <input type="text" class="input-xlarge" ng-model="message.title" /> </div> </div> <div class="control-group"> <label class="control-label">avatar : </label> <div class="controls"> <input type="file" ng-model="message.avatar" name="message[avatar]" /> </div> </div> <div class="well"> <input class="btn btn-large btn-primary" type="submit" value="建立資料"