0.0
No commit activity in last 3 years
No release in over 3 years
Rails 3 multi upload with flash based Uploadify and Rails assets pipeline
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Installation

Add this line to your application's Gemfile:

gem 'uploadify_rails'

And then execute:

$ bundle

Usage

Migration (Photo work with Paperclip):

create_table :photos do |t|
  t.integer :advert_id    # объявление
  t.integer :user_id      # пользователь (авторизованный)
  t.string  :session_id   # пользователь (гость)
  t.string  :data_content_type
  t.string  :data_file_name
  t.integer :data_file_size
  t.timestamps
end

Routes:

resources :photos, :only => [:create]
post "/photo/:id" => "photos#destroy"

Javascripts:

//= require uploadify

Stylesheets:

*= require uploadify

Model Parent (F.E. Advert):

class Advert ...
    ...
    has_many :photos, :dependent => :destroy
    accepts_nested_attributes_for :photos, :allow_destroy => true
    ...
    # Support only one relation name in just moment
    uploadify_nested_parent :relations => [:photos]
    ...

Model with Photo:

class Photo ...
    uploadify_nested_resource

Photos Controller:

class PhotosController < ApplicationController
  uploadify_nested_resource
end

Adverts Controller:

class AdvertsController < ApplicationController
  ...
  def create
    @advert = Advert.new
    @advert.build_attributes_from_params(params, current_user, session[:session_id])
    if @advert.save
      ...

View:

Example: in app/views/shared/uploadify/...

Formtastic Form Integration (@advert form):

= form.input :photos, :as => :uploadify

Enjoy!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Thanks

Thanks to https://github.com/dead-zygote for javascripts and first time realization