#201 ✓resolved
Andrey Makarov

Neo4J&Carrierwave-neo4j – File upload error

Reported by Andrey Makarov | December 2nd, 2011 @ 05:58 PM

With Neo4j 1.2.6 file uploading works fine. It was checked 16th November with

gem 'neo4j', :git => 'git://github.com/andreasronge/neo4j.git'

gem "carrierwave-neo4j", :require => "carrierwave/neo4j"

But now (after 16th November's commits, I think) file upload attempt is cause to rising error such as:

java.lang.IllegalArgumentException: Unknown property type on: #ActionDispatch::Http::UploadedFile:0x17003a2, class org.jruby.RubyObject

Model code:

class Post < Neo4j::Rails::Model
  property :title, :type => String
  property :body, :type => String

  mount_uploader :avatar, AvatarUploader
end

Controller#create code:

  def create
    Neo4j::Transaction.run do
      @post = Post.new(params[:post])
      @post.save!
      respond_to do |format|
        if @post.save
          format.html { redirect_to @post, :notice => 'Post was successfully created.' }
          format.json { render :json => @post, :status => :created, :location => @post }
        else
          format.html { render :action => "new" }
          format.json { render :json => @post.errors, :status => :unprocessable_entity }
        end
      end
    end
  end

View code:

<%= form_for(@post, :html => {:multipart => true}) do |f| %>
    <% if @post.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>

          <ul>
            <% @post.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
            <% end %>
          </ul>
        </div>
    <% end %>

    <div class="field">
      <%= f.label :title %><br />
      <%= f.text_field :title %>
    </div>
    <div class="field">
      <%= f.label :body %><br />
      <%= f.text_field :body %>
    </div>
    <div class="field">
      <label>My Avatar</label>
      <%= image_tag(@post.avatar_url) if @post.avatar? %>
      <%= f.file_field :avatar %>
      <%= f.hidden_field :avatar_cache %>
    </div>
    <div class="actions">
      <%= f.submit %>
    </div>
<% end %>

Additional info:

Remote uploading works fine:

<%= f.text_field :remote_avatar_url %>

When file_field is not filling error is not rised.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Neo4j.rb is a graph database framework for JRuby.

It provides:

* Mapping of ruby objects to nodes in networks rather than in tables.
* Storage of ruby object to a file system.
* Fast traversal of relationships between nodes in a hugh node space.
* Transaction with rollbacks support.
* Indexing and quering of ruby objects.
* Integration with Rails

People watching this ticket

Pages