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

The Archive Base Latest Questions

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

When I send wrong email, validation can’t pass but error messages in views don’t

  • 0

When I send wrong email, validation can’t pass but error messages in views don’t be displayed 🙁

I have in models:

validate :recipient_not_have_invitation, :notice => "That user have already invitation"

def recipient_not_have_invitation
  errors.add :notice, 'That user have already invitation' if InvitationToGroup.find_by_recipient_email_and_group_id(recipient_email, group_id)
end

in controller:

(...)

if @invitation_to_group.save
  Mailer.invitation_to_group(@invitation_to_group).deliver
  redirect_to root_url, :notice => "Successfully send invitation to user #{@invitation_to_group.recipient_email}"
else
  redirect_to new_invitation_to_group_path(:group_id =>  @invitation_to_group.group_id)
end

In views (invitation_to_groups/new.html.erb)

<h2>New Invitation to group </h2>
<% if notice %>
  <p id="notice"><%= notice %></p>
<% end %>

<%= form_for @invitation_to_group do |f| %>
   <% if @invitation_to_group.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@invitation_to_group.errors.count, "error") %> prohibited this user from being invitation:</h2>

      <ul>
      <% @invitation_to_group.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% 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:57:11+00:00Added an answer on May 25, 2026 at 11:57 pm

    The problem is that you are using redirect_to after else in your controller. So you are going to new action and in this action you have InvitationToGroup.new. So you build new object without errors 😉 You need to use render method instesd.

    PS. you should really consider using “formtastic”. It will imporve your code in views. Please watch this two railscasts: http://railscasts.com/episodes/184-formtastic-part-1 and http://railscasts.com/episodes/185-formtastic-part-2

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

Sidebar

Related Questions

i tried to send html email but i guess i am doing sth wrong
I have to send an email which contains a picture and some text around
I have a very complex system (100+ threads) which need to send email without
I have been struggling with trying to send an email with an attachment using
am using system.net.mail to send email as shown below, but its too slow. it
I am using this function to send an email, but this does nto work..
I am getting the following error when trying to send an email message where
I'm trying to send an email with custom headers but for some reason they
I am trying to send Email using Java Sockets but cannot seem to send
I'm trying to send an email using the GMail SMTP server. I have 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.