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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:50:03+00:00 2026-06-13T10:50:03+00:00

How can i display Rails error messages without brackets and quotes? When a error

  • 0

How can i display Rails error messages without brackets and quotes?

When a error message appears, it looks like:

["please fill out domain"]["please fill out email"]

How can i remove the brackets and the quotes?

Model

validates :domain,
          :presence => { :message => 'please fill out domain'},
          :uniqueness => { :message => 'domain already registered', :case_sensitive => true }
validates :email,
          :presence => { :message => 'please fill out email'},
          :uniqueness => { :message => 'email already registered', :case_sensitive => true }

Controller

I’m specify the url of the template (see format.html) cause i’m using a different controller

def create

  respond_to do |format|
    # save form data
    @login = Login.new(params[:login])

    # if validation fails, throw error messages
    if !@login.save
      flash[:error] = @login.errors.to_a if @login.invalid?
    end

    # render landingpage
    format.html { render :template => 'landingpage/index' }
    format.js { render :action => 'create' }

  end

end

create.js.erb

<% if @login.errors.any? %>
  // error

  var error_string = "";
  <% @login.errors.values.each do |msg| %>
    error_string += "<%= msg %>";
  <% end %>

  $("#flash_messages").html(error_string);

<% else %>
 // no error
<% end %>

View

<div id="flash_messages"></div>
  • 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-13T10:50:05+00:00Added an answer on June 13, 2026 at 10:50 am

    When you iterate over the full error messages, you will already receive clean texts

    In your create.js.erb, write the iteration as below:

    @login.errors.full_messages.each do |msg|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails I'm trying to get an error message like The song field can't
How can i display the validation error messages just below the form field rather
I can display a simple Visual Basic inputbox from a PowerShell script like this:
How can I send the error messages that are happening in the model code
How i can display all applications icons and name which are installed in device
how i can display Name - LastName with ViewBag? <h2> @{ViewBag.Name;} - @{ViewBag.LastName;} </h2>
In Visual Studio you can display the Call hierarchy of a single function. What
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Examotion has a player that can display the image for svg files as a
Is there any firefox addon which can display my asp.net page viewstate size.... Any

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.