This repository was archived by the owner on Aug 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ def image
77 # rails_blob_path(object.image, only_path: true) if object.image.attached?
88 if self . object . image . attached?
99 object . image . map do |img |
10- p "CRIS" , url_for ( img )
1110 url_for ( img )
1211 end
1312 end
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ async function postClub(club) {
1313 console . log ( errors ) ;
1414 throw new Error ( errors ) ;
1515 }
16-
1716 return response . json ( ) ;
1817}
1918
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function CreateClub() {
1111 name : "" ,
1212 address : "" ,
1313 district : "" ,
14- image : null
14+ image : [ ]
1515 } ) ;
1616 const [ schedule , setSchedule ] = React . useState ( {
1717 "monday-friday" : {
@@ -31,8 +31,7 @@ function CreateClub() {
3131
3232 function handleChange ( e ) {
3333 if ( e . target . name === "image" ) {
34- console . log ( [ ...e . target . files ] ) ;
35- setFields ( { ...fields , image : e . target . files [ 0 ] } ) ;
34+ setFields ( { ...fields , image : [ ...fields . image , ...e . target . files ] } ) ;
3635 } else {
3736 setFields ( { ...fields , [ e . target . name ] : e . target . value } ) ;
3837 }
@@ -50,7 +49,13 @@ function CreateClub() {
5049 e . preventDefault ( ) ;
5150 const formData = new FormData ( ) ;
5251 Object . keys ( fields ) . forEach ( key => {
53- formData . append ( key , fields [ key ] ) ;
52+ if ( key === "image" ) {
53+ fields [ key ] . forEach ( file => {
54+ formData . append ( "image[]" , file ) ;
55+ } ) ;
56+ } else {
57+ formData . append ( key , fields [ key ] ) ;
58+ }
5459 } ) ;
5560 const { results } = await getCoords (
5661 `${ fields . address } , ${ fields . district } `
You can’t perform that action at this time.
0 commit comments