last day (17 days later) » 

8:59 PM
0
A: Rails uploads for new object

LeantraxxxI made a Gem to solve this kind of problem. It works on top of paperclip and is not intrusive. To enable the functionality, you need to replace paperclip's has_attached_file with has_attached_upload. Using Rails Pallet gem... First, you need to upload the file to your server performing POST /upl...

 
Awesome. I'll look into it. Can you speak at all to refile as a paperclip replacement?
also is this rails 5 compatible?
 
It's a paperclip's complement, not a replacement. You replace has_attached_file by has_attached_upload only in the models you need. I didn't test it in Rails 5, Rails 4.2 only.
 
I just forked and changed gemspec for rails 5. Just got a 404 for /uploads. Do I need to add a post in routes.rb?
 
You need to run the installer rails generate rails_pallet:install to mount the gem and get the endpoint.
 
Yes, already generated. Using dropzone with POST to /uploads' and paramName: "file"`...should be all I need?
 
8:59 PM
To create the file, yes. After that, you will see the identifier on response.
 
Leantraxxx...having a bit of trouble
I've got my routes.rb:

RailsPallet::Engine.routes.draw do
resources :uploads, only: [:create], defaults: { format: :json }
end
possibly a rails5 issue...still getting a 404 response
 
if you run rake routes? what do you get?
 
Nothing related to RailsPallet::Engine
waaaait...
 
you routes.rb needs to be like this...
Rails.application.routes.draw do
mount RailsPallet::Engine => '/'
end
 
ah
no resources :uploads??
 
9:04 PM
the engine adds the route for POST /uploads
 
kk, added and restarting server
 
but the installershould add mount RailsPallet::Engine => '/' in your routes.rb
 
ok, we're warmer
Before process_action callback :verify_authenticity_token has not been defined
 
I think that is a Rails 5 problem
 
Shooot
I believe so
The trace is Rails5
 
9:06 PM
but, you can create your own uploads controller
 
I see in the README
If I create per readme, it'll override engine controller?
 
mmm I think you need a new location
let me see
 
cool. Thanks for your help!
I'm signing off. I'll revisit all this monday.
 
No problem. You can run rails g rails_pallet:upload_controller Attachments Application to create the controller ;)
and then POST /attachments
 

  last day (17 days later) »