1
votes

I'm currently building a Ruby on Rails app (Ruby 2 - Rails 4).

I have chosen Cloudinary and Attachinary as my choice to upload and store photos/document attachments for the application.

I have setup the User Model in my application with:

has_attachment :avatar, :accept => [:jpg, :png, :gif]

Now I have set this up I wish to create a form to upload an avatar image for the User profile.

<div class="row">
    <div class="col-md-4 col-xs-12">
        <div class="profile-image" align="center">
            <img src="<%= asset_path "person.png" %>" width="180px" height="180px" alt=""/>
        </div>

       <div class="dropzone-wrapper">
            <div class="table" class="files" id="previews">
                <div id="file_template" class="file-item">
                    <!-- This is used as the file preview template -->
                    <div class="preview-image">
                        <span class="glyphicon glyphicon-paperclip"></span>
                        <img data-dz-thumbnail />
                    </div>

                    <div class="info-file">
                        <div class="name" data-dz-name></div>
                        <strong class="error text-danger" data-dz-errormessage></strong>
                        <div class="size" data-dz-size></div>
                    </div>

                    <div>
                        <div data-dz-remove class="cancel-btn cancel">
                            <span class="glyphicon glyphicon-remove"></span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="dropzone" id="dropzone">
          Drop new image or click.
          <%= form_for :user, do |f| %>
          <%= attachinary_file_field_tag 'user[avatar]', :user, :avatar %>
          <% end %>
            </div>                
        </div>
    </div>

No luck, I know I must be doing something wrong just can't see it with my own eyes.

Thanks for taking a look.

1

1 Answers

2
votes
<%= form_for :user, do |f| %>
    <%= attachinary_file_field_tag 'user[avatar]', :user, :avatar %>
<% end %>

Should be:

<%= form_for :user, do |f| %>
    <%= f.attachinary_file_field :avatar %>
<% end %>