Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:25:54+00:00 2026-06-08T03:25:54+00:00

When adding :remote => true to my edit form in my rails app, submits

  • 0

When adding :remote => true to my edit form in my rails app, submits work fine, but now my program does not show error messages. I have tried multiple solutions but none of them have worked. Can anyone point me in the correct direction to solve this problem? If the entry is successfully saved, a notice message is added to a div, something I wrote in edit.js.erb. I tried to also have the ‘error messages’ added to an error message div but @entry.errors.any? never returns true when I add :remote => true.

This is the edit div in my form I am trying to update.

<div id="errors">
  <% if @entry.errors.any? %>
      <h2><%= pluralize(@entry.errors.count, "error") %> prohibited this entry from being saved:</h2>

      <ul>
      <% @entry.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
  <% end %>
</div>

I also have its contents in a partial and my edit.js.erb tries to update the div with the newly rendered partial, but now @entry.errors.any? is not returning true here anymore.. Here is also my controller…

# GET /entries/1/edit
def edit
  @entry = Entry.find(params[:id])

  respond_to do |format|
    format.html
    format.js
  end
end


def update
  @entry = Entry.find(params[:id])

  respond_to do |format|
    if @entry.update_attributes(params[:entry])
      format.html { redirect_to edit_entry_path(@entry), notice: 'Entry was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @entry.errors, status: :unprocessable_entity }
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:25:56+00:00Added an answer on June 8, 2026 at 3:25 am

    I created a partial, _errors.html.erb

    <% if @entry.errors.any? %>
        <h2><%= pluralize(@entry.errors.count, "error") %> prohibited this entry from being saved:</h2>
        <ul>
        <% @entry.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
        </ul>
    <% end %>
    

    I created update.js.erb

    $("#errorlist").html("<%= escape_javascript(render('errors')) %>");
    

    where #errors refers to a in my form, and the errors partial. Finally my controller is like this now.
    # PUT /entries/1
    # PUT /entries/1.json
    def update
    @entry = Entry.find(params[:id])

    def update
      @entry = Entry.find(params[:id])
    
      respond_to do |format|
        if @entry.update_attributes(params[:entry])
          format.html { redirect_to edit_entry_path(@entry), notice: 'Entry was successfully updated.' }
          format.json { head :no_content }
        else
          format.html
          format.js
        end
      end
    end
    

    Also, since I only want ajax on my edit form, and not my create form (adding :remote => true to _form.html.erb effects both) I also changed this line in _form.html.erb from

    <%= form_for @entry, :remote => true, :html => {:id => "editform", :multipart => true} do |f| %>
    

    to

    <%= form_for @entry, :remote => current_page?(:controller => 'entries', :action => 'new') ? false : true, :html => {:id => "editform", :multipart => true} do |f| %>
    

    Thank you for the help, those who helped me achieve my solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does not the MouseLeftButtonUp on my Canvas fire in my WPF app? Here
I'm trying to implement a generic way of adding remote validation to xVal /
I have a Rails 3 app that is trying to perform some controller action
I am reading this tutorial : http://sleekd.com/general/adding-multiple-images-to-a-rails-model-with-paperclip/ because i need Save the product images
I have a php script that is reading a remote CSV file, and adding
email1: { required: true, blacklist: true, beanEmailValidator: true, minlength: 6, maxlength: 70, remote: {
I have a simple Rails 3.1.rc6 app that I'm using to try to test
I'm adding a record into remote mysql database and after that I want to
I have a node form that the author should be able to edit, unless
Working with ajax on a rails 3.1 app, i need to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.