Closed chiragagrawal closed 7 years ago
Hi @chiragagrawal
Thanks for reporting this.
CSV issues are hard to debug and extremely time consuming to investigate.
You should provide all the information required in the Contributing Guidelines
The best you can do to speed up things is to share a new application with just the minimum amount of code to reproduce the issue (such as: one model, one controller, one form with two file fields), the minimum amount of gems (the basic rails gemfile + csv + csv_simple-form + paperclip + mongoid_paperclip)
Please also make sure to use the latest version of CSV because I do not support CSV for Rails 4
Please also note that you can copy & paste your code here.
https://guides.github.com/features/mastering-markdown/
Eg:
```rb
class MyModel
def my_method
end
end
.item{:id => "item#{item.id}"}= item.body
will result into:
```rb
class MyModel
def my_method
end
end
.item{:id => "item#{item.id}"}= item.body
Hello @tagliala
It is not about uploading CSV, it is all about uploading images, which gives me error.
You can find my code below for the _form which I am rendering on Bootstrap modal also I am attaching my code from the controller. model and js file
_form.html.haml
<%= simple_form_for(hotel, url: url, remote: true, multipart: true, html: {role: :form, 'data-model' => 'hotel', class: 'form-horizontal'}, authenticity_token: true, wrapper: :horizontal_form) do |f| %>
<% debugger %>
<div class="modal-body">
<% if f.object.new_record? %>
<%= f.input :import_type, as: :select, collection: Hotel::IMPORT_TYPES.map{|v, k| [k, v]}, input_html: {class: "chosen-select import_type"} %>
<div id="imported" style="display: none">
<%= f.input :file_import, as: :file, wrapper: :horizontal_file_input, class: 'form-control' %>
</div>
<% end %>
<div id="manual_fill">
<%= f.input :name %>
<%= f.input :image, as: :file, wrapper: :horizontal_form, hint: "The image must be square and at least 200 x 250 pixels, and no larger than 5 MB in size." %>
<%= f.input :tineri_tips_image, as: :file, wrapper: :horizontal_file_input, class: 'form-control', hint: "The image should be exact 373x200." %>
<%= f.input :contact_ids, as: :select, collection: f.object.contacts.map{|v| [v.fullname, v.id]}, input_html: {class: 'chosen-select', name: 'hotel[contact_ids][]'} %>
<div id="contacts">
<div class="row">
<%= f.simple_fields_for :contacts do |contact| %>
<div class="col-sm-2"></div>
<div class="col-sm-10">
<% if contact.object.new_record? %>
<%= render 'contact_fields', f: contact %>
<% end %>
</div>
<% end %>
</div>
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<div class="links">
<%= link_to_add_association 'Add Contact', f, :contacts, class: 'btn btn-primary btn-border mb-10' %>
</div>
</div>
</div>
</div>
<%= f.input :address %>
<%= f.input :city %>
<%= f.input :province %>
<%= f.input :country_id, as: :select, collection: Country.order(name: :asc).map{|v| [v.name, v.id]}, input_html: {class: "chosen-select"} %>
<%= f.input :description, as: :ckeditor, input_html: { ckeditor: {toolbar: 'mini'} } %>
<%= f.input :use_description_as_tineri_tip, wrapper: :horizontal_boolean do %>
<%= check_box_tag "user_use_description_as_tineri_tip", true, f.object.use_description_as_tineri_tip == true, class: 'onoffswitch-checkbox',name: "hotel[use_description_as_tineri_tip]" %>
<label class="onoffswitch-label" for="user_use_description_as_tineri_tip">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
<% end %>
<%= f.input :tineri_tip_description, as: :ckeditor, input_html: { ckeditor: {toolbar: 'mini'} } %>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default btn-border" type="submit">Submit</button>
<button class="btn btn-default btn-border" data-dismiss="modal" type="button">Cancel</button>
</div>
<% end %>
On model, I have validations like
has_mongoid_attached_file :image,
:path => ':rails_root/public/uploads/hotels/:id/:style.:extension',
:url => "/uploads/hotels/:id/:style.:extension",
:styles => {
:original => ['1920x1680>', :png],
:small => ['100x100', :png],
:medium => ['250x250', :png],
:large => ['540x960>', :png]
}
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
can_attach_from_remote_url :image
validates :image, dimensions: { width: 200, height: 250 }
Please help me with this.
It is not about uploading CSV, it is all about uploading images, which gives me error.
Hi, CSV = ClientSideValidations :)
I am rendering on Bootstrap modal
Please take a look at this wiki: https://github.com/DavyJonesLocker/client_side_validations/wiki/Bootstrap-Modal-Validations
Sorry for being pedantic but the more complexity you are adding to your bug report, the more is difficult to understand the issue.
Contributing guidelines are quite clear:
Submitting a new issue
If you need to open a new issue you must provide the following:
- Version of ClientSideValidations
- Version of Rails
- Code snippet from your model of the validations
- The form code from your template
- The resulting HTML
Failure to include the above mentioned requirements will result in the issue being closed.
If you want to ensure that your issue gets fixed fast you should attempt to reproduce the issue in an isolated example application that you can share.
Note that I'm not going to close this issue, but if you are interested in me taking a look, you should provide all the information needed.
Please also remember that ClientSideValidations 4.x is not supported, so you should make sure the issue is still present on CSV 9.3.3
No feedback, closing here
Hello,
I am using simple_form along with client side validations gem and mongoid:peperclip for the attachments, everything is working fine with one attachment but it is giving me issues with two file fields.
I am creating user with the help of modal and running create request as js, I am not refreshing the page and I have two file fields for attaching images or any file, on press of submit button, if validations gets failed, Issue 1 it is replacing the second image with the first one and the first file field is empty now. Issue 2 If you again press submit button, it will make the first file field disappears.
Here, I am attaching the code of my form, I am attaching screen shots to make the errors clear.
I think, there is some issue with client_side_validation gem. form.txt
Please change the extension of form.txt to form.html.haml.
Thanks in advance for any help