I have form in views/users/show.html.erb
<% form_for [@user,Wall.new] do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :message %><br />
<%= f.text_area :message,:rows=>4 %>
</p>
<%= f.hidden_field :sender_id,:value=>current_user.id %>
<p><%= f.submit "Submit" %></p>
<% end %>
and I have this validation method in Models/wall.rb
validate :isfriend?
def isfriend?
errors.add(:message,'You have to be a friend to send message') if !Friendship.find(:first,
:conditions=>"requester_id=#{self.sender_id} and accepter_id=#{self.receiver_id} and status='accepted'
or requester_id=#{self.receiver_id} and accepter_id=#{self.sender_id} and status='accepted'")
end
Everything is fine validation is working and saving disable also it gives error message but it's not normal way it gives message like that
ActiveRecord::RecordInvalid in WallsController#create
Validation failed: Message You have to be a friend to send message
RAILS_ROOT: C:/Users/MaDOnos/Documents/NetBeansProjects/tttttt
How can show this error message in fair way.