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 6636221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:09:31+00:00 2026-05-25T23:09:31+00:00

I did a simple rails form with two user inputs , name and email.

  • 0

I did a simple rails form with two user inputs , name and email. I’m using rails 3.1, so I used :remote => true in my form_for tag. I also created a create.js.erb and added corresponding format.js in the users_controller.rb.

I added the following lines in create.js.erb

$(document).ready(function(){
    $('body').html("<h1>Registration Successful</h1>")
});

Now the problem is that when I click the submit button, with empty fields, it does not show validations error messages that I have added in the user.rb model file. Instead, it will show me registration successful message.

Is there some easy way to circumvent this problems in rails. Also please note that I’m very bad at javascript, so please be nice to me.

controller code for create

  def create
    @user = User.new(params[:user])

    respond_to do |format|
      if @user.save
        #UserMailer.registration_confirmation(@user).deliver
        format.html { redirect_to @user, notice: 'User was successfully created.' }
        format.js
      else
        format.html { render action: "new" }
        format.js
      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-05-25T23:09:32+00:00Added an answer on May 25, 2026 at 11:09 pm

    The reason it doesn’t show the errors is because you are not telling it to, you are simply telling it to write “Registration Successful”. You could try:

    <% @user.errors.full_messages.each do |error| %>
      $('body').prepend("<h1><%=error%></h1>");
    <% end %>
    

    This assumes that your controller has the following or something similar:

    @user = User.create(params[:user])
    

    Hopefully this is enough to get you started. If not, some controller code will be required to help further.

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

Sidebar

Related Questions

Say if I did a simple scaffold like rails g scaffold user name:string .
New to rails and making a simple blog in rails 3.1.3 where a User
I am writing unit tests for a simple user model in rails and just
I was playing around with recursion and did this simple function. I was assuming
Perhaps a simple to be answered question, but I did not find a satisfying
Ok I know this is simple, in fact damn simple, I did this in
I did one sample application using WebView, in that web view the URL comes
Did you used Dynamic websites before? you see its a good way for making
I am new to rails and want to do a simple routing to root
I am trying to work with tarnfeld's PusharChat-Rails I downloaded the file, did the

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.