Hi I have a model class SDResolution.It has fields code and solution.I have to make the solution not empty .So for that I wrote validates_presence_of :resolution in the model.So from the view when I click save nothing is saved to database.This is what I need.But no error messages are printed and the view goes to next window..How can I print error messages in the current window? Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that''s a question of your controller logic.
do it something like that:
def update
@sdresolution = SDResolution.find(params[:id]
if @sdresolution.update_attributes(params[:sdresolution]) then
...render next view---
else
redirect_to edit action (or just render edit view again)
end
end
in your view (for edit) just add
<%= error_messages_for(:SDResolution) %>
this will display error messages if there are any on the @sdresolution
object
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi
I am using ajax submit to remote here..I could succeed this
validation on another place without ajax..I am attaching the code for
this .Could you please go through it and make a suggestion?
Thanks
Sijo
Attachments:
http://www.ruby-forum.com/attachment/1865/sdresolution.zip
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
had a very short look at it (sorry, have some work to do) but it seems in your action you do: @update_sd_ticket_resolution=@sd_ticket_resolution.update_attributes(params[:sd_resolution]) using @sd_ticket_resolution while your view uses: <%= error_messages_for ''service_desk_resolution'' %> this should be <%= error_messages_for ''sd_ticket_resolution'' %> to render the errors that may be on @sd_ticket_resolution after the update_attributes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Thanks for your reply..Stil have problem .Could you please look at the code when get time? Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi everyone, I am a total novice with Ruby on Rails and I''m having a problem using validates_presence_of. I''m following a tutorial from a book called "Ruby on rails: up and running" and I''m not getting the result I expect (and what the book expects). Here''s my model: class Photo < ActiveRecord::Base validates_presence_of :filename end I tested this using rails console:>> photo=Photo.new=> #<Photo id: nil, filename: nil>>> photo.save=> true>> puts photo.filenamenil I expect (and so does the book) that photo.save returns false and nothing is saved to the database, but it saves anyway. Any ideas what I am doing wrong? Forgive me if it''s something ridiculously simple that I''ve overlooked, it is quite late ;) If you could point me in the right direction I would be greatly appreciative. Cheers, Adam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---