RailsCasts Pro episodes are now free!

Learn more or hide this

Dave Lehman's Profile

GitHub User: dlehman

Comments by Dave Lehman


Yes, there are some changes with how routes are defined in Rails 4.

Go into config/routes.rb and change your /auth/:provider/callback route to accept :post requests:

# Rails 4 route syntax
match '/auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
# or, explicitly accept post requests
post '/auth/:provider/callback' => 'sessions#create'

I had the same perennial desire to be able to add images to a gallery without having to save it first.

I found a sample app demo of jquery-file-upload using carrierwave on GitHub that did almost what I wanted. I added the ability to be able to add images before the gallery record had been saved.

I generated a unique token (GUID) when a "New Gallery" form is displayed. This token is saved with each image as it's uploaded and saved as an independent "Picture" record. When the gallery is finally saved, it finds any Picture records with the matching token, and adds them as children.

Note: if you upload images, but abandon the form before saving it, you do get orphaned pictures. You would need to clean these up periodically.