nicofraisse / rails-poutinerank

Poutine website first attempt
1 stars 1 forks source link

Create public API for cloudinary upload #11

Open metalogica opened 4 years ago

metalogica commented 4 years ago

Currently users need the cloudinary API key associated with Nicolas His Poutine Excellency Fraisse to upload photos of marvellous (or revolting) poutines 🍟 ...

Let's do some research and find a way to allow any admin user on the website to upload photos.

Full error message below.

ActiveStorage::IntegrityError in RestaurantsController#create
Must supply api_key

Problematic code:

    @restaurant.json_address =  Geocoder.search(@restaurant.address).first
    @restaurant.user = current_user
    if @restaurant.save
      redirect_to restaurant_path(@restaurant)
    else
      render :new

Full request shown below:

{"authenticity_token"=>"BtH/m+lWLKXDcYiAsMHTUveva+1YjpdBRp5k/eWx4YBJtn2XnPEC5933zID5qXawvISFtaBZlZnj93ppsUkvrQ==",
 "restaurant"=>
  {"name"=>"test",
   "address"=>"5259 St Urbain",
   "poutine_price"=>"100",
   "restaurant_category_id"=>"3",
   "photo"=>
    #<ActionDispatch::Http::UploadedFile:0x00007fbf3ae98080
     @content_type="image/jpeg",
     @headers="Content-Disposition: form-data; name=\"restaurant[photo]\"; filename=\"dark-side-2.jpg\"\r\n" + "Content-Type: image/jpeg\r\n",
     @original_filename="dark-side-2.jpg",
     @tempfile=#<File:/var/folders/mj/_hcl4gm140xcw1xsrk746xn00000gn/T/RackMultipart20200616-64587-19ivb3g.jpg>>},
 "commit"=>"Soumettre le restaurant"}
metalogica commented 4 years ago

Ignore me, your Poutine Highness @nicofraisse .

I believe you must simply provide me with .env file and this issue will be solved.

πŸ™

metalogica commented 4 years ago

Chez Claudette: Smoked Poutine, 12 CAD. Smoked meat poutine with API key, 12.5 CAD