Report abuse


			
Schema
------
  create_table "videos", :force => true do |t|
    t.column "name",         :string
    t.column "description",  :text
    t.column "filename",     :string
    t.column "rel_path",     :string
    t.column "author",       :string
    t.column "time",         :time
    t.column "no_views",     :integer
    t.column "no_comm",      :integer
    t.column "streamable",   :boolean
    t.column "downloadable", :boolean
    t.column "created_at",   :datetime
    t.column "created_by",   :string
    t.column "uploaded_at",  :datetime
    t.column "updated_by",   :string
  end

Controller
----------

  def upload_video
    if request.post?
!!      file = params[:video].delete(:file) 
      @video = Video.new(params[:video])
      @video.filename = (params[:video].original_filename)
      @video.rel_path = (params[:video].local_path)
      if @video.save?
!!        f = File.new(RAILS_ROOT + "/public/videos/download/#{(file.original_filename)}", "w")
!!        f.write(file.read)
!!        f.close
        flash[:notice] = 'File Saved!'
        redirect_to :action => 'list_galleries'
      else
        flash[:notice] = 'File was not saved!'
        render :action => 'upload_video'
      end
    else
      flash[:notice] = 'Cannot submit information'
      render :action => 'upload_video'
    end  
  end

View
----

Upload Video

<%= start_form_tag({:action => 'upload_video'}, {:multipart => true}) %>


<%= text_field 'video', 'name' %>


<%= text_area 'video', 'description' %>


!! <%= file_field_tag 'video[file]' %>

<%= submit_tag 'Create' %> <%= end_form_tag %> <%= link_to 'Back', :action => 'list' %> Model ----- class Video < ActiveRecord::Base end Error Traceback --------------- undefined method `stringify_keys!' for # c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1668:in `attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1505:in `initialize_without_callbacks' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:225:in `initialize' #{RAILS_ROOT}/app/controllers/galleries_management_controller.rb:35:in `new' #{RAILS_ROOT}/app/controllers/galleries_management_controller.rb:35:in `upload_video' -e:4:in `load' -e:4