Displaying 7 results from an estimated 7 matches for "validates_attachment_presence".
2012 Jan 19
0
Problem in testing with separate validation of :attachment_file_name
Using: RSpec, Shoulda, Paperclip (including matchers)
Example Model
class Example < ActiveRecord::Base
has_attached_file :attachment
validates_attachment_presence :attachment
validates_format_of :attachment_file_name, :with => /\.(png|jpe?g)$/
end
Example Test
require ''spec/helper''
describe Example do
it { should validate_attachment_presence(:attachment) }
it { should validate_format_of(:attachment_file_name).
with(...
2012 Aug 18
2
Paperclip images are not stored in my directory
...quot;100x100#", :large =>
"500x500>", :thumb => "60x60>" },
:url => "/assets/users/:id/:style/:basename.:extension",
:path =>
":rails_root/public/assets/users/:id/:style/:basename.:extension"
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 5.megabytes
validates_attachment_content_type :photo, :content_type => [''image/jpeg'',
''image/png'']
Please advice me...
--
You received this message because you are subscribed to the Google Group...
2010 Jun 09
4
rails+sinatra sent image
Hi!
I have simple rails application - users with name and avatar and in
sinatra I want to create new user.
form for new user
<form action="/users/create" enctype="multipart/form-data"
method="post">
<p>
<label for="name">Name: </label>
<input type="text" id="name" name="user[name]" >
2013 Oct 10
12
What's the best way to approach reading and parse large XLSX files?
...ser/inventory",
:path=>":rails_root/tmp/users/uploaded_files/inventory/inventory.:extension"
has_attached_file :material_list, :url=>"/:current_user/material_list",
:path=>":rails_root/tmp/users/uploaded_files/material_list/material_list.:extension"
validates_attachment_presence :material_list
accepts_nested_attributes_for :material_list, :allow_destroy => true
accepts_nested_attributes_for :inventory, :allow_destroy => true
validates_attachment_content_type :inventory, :content_type =>
["application/vnd.openxmlformats-officedocument.spreadsheetml....
2008 Jun 09
10
Testing file attachment with Paperclip
Does someone have an example on faking a file upload for just ensuring
it gets called, without actually uploading the file to s3.
I thought that stubbing Model.has_attached_file would be enough, but
it doesn''t seem so ...
This is what I did:
Video.stub!( :has_attached_file ).with( :name ).and_return( true )
has_attached_file is from paperclip, it gets mixed to the model.
1)
2014 Feb 18
0
How to Test Multimodel Paperclip attachments?
...ads, allow_destroy: true
end
Upload.rb
class Upload < ActiveRecord::Base
belongs_to :car
has_attached_file :upload, styles: { medium: '300x300>', thumb:
'100x100>' }
validates_attachment_content_type :upload, content_type:
/\Aimage\/.*\Z/
validates_attachment_presence :upload
end
As you can see there is a has_many and belongs_to relationship between
the two.
car_spec.rb
require 'spec_helper'
describe Car do
before do
@car = Car.new(FactoryGirl.attributes_for(:car))
end
subject { @car }
it { should respond...
2009 Nov 10
4
Model spec for file upload with paperclip and fastercsv
I just started my ImportsController and was this was really the way to
go:
////////import.rb/////////////////
class Import < ActiveRecord::Base
has_attached_file :csv
validates_attachment_presence :csv
after_save :process_csv
private
def process_csv
FasterCSV.foreach( csv.path) do |row|
#TODO
end
end
end
/////////import_spec.rb/////////////////
require ''spec_helper''
describe Import do
it "should should succeed creating a valid Import from...