The gem 'remotipart' does not display any server errors in Rails 4

Currently, I have included the 'remotipart' gem in my Gemfile like this: gem 'remotipart'

This is defined in my form view new.html.erb

<%=form_for @user, remote: true, html: { multipart: true, class: 'user-form' } do |f| %>

    <div id='file_browse'>
      <%= f.file_field :image, :id => 'file_browse' %>
    </div>
    <div class="actions">
      <%= f.submit %>
     </div>    
<%end%>

The Controller method looks like this :

def create
  respond_to do |format|
    if @user.save
      format.js
    end
  end
end  

Next, I have a file called create.js.erb which contains:

<% if remotipart_submitted? %>
  alert('submitted via remotipart')
<% else %>
  alert('error in uploading image')
<% end %>

However, when attempting to use this setup, I encountered an error with code 413: Request Entity Too Large. Despite this error occurring at the server level, it does not display on the page. As a result, my alert message is not being triggered to catch the error. I am seeking assistance in resolving this issue without resorting to using client_max_body_size 2M; as a workaround. The main challenge is that the error stems from nginx directly and bypasses the Rails application.

Answer №1

The error you're encountering is coming from ngnix, not rails.

To resolve this issue, you can adjust the client_max_body_size attribute in your Nginx configuration.

For more information on how to do this, check out this helpful article.

Answer №2

To potentially assist you, consider implementing the following approach:

Within your create.js.erb file

<%= custom_response do %>
  <% if custom_submitted? %>
     alert('submission successful')
  <% else %>
     alert('error encountered during image upload')
  <% end %>
<% end %>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Node.js to read and replicate a JSON file

As someone who is relatively new to the world of NODE.JS, I am eager to level up my skills. Currently, I have a NODE.JS script that gathers data from a feed, resulting in a large JSON file. This file is then used by webpages and mobile apps to display con ...

Formatting text to automatically continue onto the next line without requiring scrolling through long blocks of

I have a unique Angular project with a terminal interface that functions properly, maintaining a vertical scroll and automatically scrolling when new commands are entered. However, I am struggling to get the text within the horizontal divs to wrap to the ...

Fetching data from the server using Angular and parsing it as JSON

Can anyone provide some insight on the best way to use jsonObjects in ng repeat? Here is my code: This is the response I get from PHP: die(json_encode(array('sts'=>'success', 'title'=>'*****', 'msg' ...

Obtain the JSON object by provided criteria

In the given JSON data, how can I access an object based on the provided applicationName? { "apps": [ { "applicationName": "myTestApp", "keys": [ { "key": "app-key", ...

The functionality of Javascript Array.splice suddenly malfunctioned in my Angular application

While working on a project in Angular 4, I encountered a situation where I needed to batch through an array of ids. I would send the removed items to an Observable function, and upon the subscription returning, I would check the remaining array before loop ...

Utilizing "this" correctly within JavaScript objects

Can someone help me understand how to access enums.ROCK within the prop in the code snippet below? I keep getting an error that says Uncaught TypeError: Cannot read property 'enums' of undefined. Please pay attention to the comment ERROR LINE. c ...

What are the steps to incorporate Custom Fields with Devise on a MongoDB database?

Currently, I am attempting to personalize Devise on Rails using mongoid. I've successfully set up devise and now have the sign up and sign in pages visible. However, these pages only include fields for email, password, and password confirmation. My go ...

Formulate a targeted search request according to the selected radio button option

I'm working on a form that looks like this: <form> <input type="text" id="searchedWord" class="form-control form-control-lg" value="words here"/> <button type="submit" id="f ...

json keys with spaces

I need help with a JSON structure I am working with: data: { First Name: "Robert", Last Name: "Smith" } I'm trying to access the data using javascript like this: "data.First Name" I know this is incorrect syntax. How can I extract the information fr ...

Shuffling specific table cells to exchange positions

I am attempting to create a script that will allow certain td elements (but not all) in different tr elements to switch places with the ones directly above or below them. My goal is to only target the last 3 td elements in each row, rather than the entire ...

Is it possible to keep adding the keys of an array to themselves until reaching a specified limit

Given an array var ary = [5,10,28,50,56,280], I am exploring the idea of generating all possible combinations or subsets of this array until a certain threshold is reached. The objective is to store this limit in a variable and collect all the elements be ...

Managing Ajax Requests in Browser and Clearing Them from Network Tab Once They're Finished

Is there a limit to the number of AJAX requests that can be handled in a browser's network tab? If I were to send 100,000 AJAX requests, would the network tab actually show all 100,000 requests or is there a maximum capacity it can handle? Additionall ...

The AR.js documentation example is not functional when initially tested

Struggling with AR.js, I decided to start fresh and go back to basics. My goal is to place a gltf file on a custom marker. I referred to the documentation at () for the image tracking example: <script src="https://raw.githack.com/AR-js-org/AR.js/ ...

What is the process for transferring `Parentobject1` to `childobject2` and `childobject3` in Three.js?

I have created two objects doubleSquare and doubleSquare1. I was expecting the output to be Double Line Square Object, but I have tried two different formats and have not achieved the desired output. Can someone please provide me with a solution? I have lo ...

Tips for organizing a list of strings into columns within a React Bootstrap Table 2 without overflowing the designated columns

While working on rendering data in tabular form using react-bootstrap-table, I encountered an issue where the data in one column was overlapping with data from other columns. In order to maintain a fixed layout, I added the CSS layout:fixed, which was a ne ...

Verify if the specified date (in string form) has already occurred or is upcoming using JavaScript

I need to determine if the start date of a given date range string (e.g. 12/20/12-12/24/12) has already passed the current date. Is there a way to achieve this using JavaScript or jQuery? ...

Step by step guide on uploading files using Vue.js and Express.js

Hello there, I am new to Vuejs and Express and I'm looking to practice my skills. Currently, I am attempting to build a User Profile with an image upload feature using Vuejs and ExpressJs but unfortunately, none of the files or text are uploading as ...

What could be causing the issue with Ajax.BeginForm functionality not working as expected

I have spent time researching similar questions, but I am still unable to make it work. Within a form, I have several radio buttons. Instead of having the user select an option and then click a submit button, I would like the form to be submitted when a r ...

Removing the cloned element is not possible

In my grid, there is a feature where hovering over a box creates a clone of that box which is positioned directly above it (using z-index/overlay). Once the user moves the cursor away from the box, an animation should play, and at the end of it, the box sh ...

Leverage the https module within your React Native application

How can I integrate the https standard library module from Node.js into a React Native project? Specifically, I need to use https.Agent for axios. Is there a recommended approach for achieving this integration? ...