HighDots Forums  

how to handle my comment validation errors

Ruby On Rails Talk Ruby On Rails programming language mailing list


Discuss how to handle my comment validation errors in the Ruby On Rails Talk forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bingo bob
 
Posts: n/a

Default how to handle my comment validation errors - 11-06-2009 , 04:32 AM






I've got a resorts view, shows details of a ski resort. Under the resort
description I allow users to leave comments on the resort - works fine.

- Resort has many comments.
- Comment belongs to resort.

However, slight problemo - the comment form on my resorts page creates a
new comment via the Comments Controller (new and create actions are
available to the public). This works fine.

But how oh how do I send back the comment validation errors to the
Resorts show view when redirected from the comments controller - I'd
like to do this.

It's horrible at the moment - I'm using the flash to display feedback to
the user, it's not ideal.

How should I handle this - surely a common situation?

When I redirect back to the resort can I pass back the comment complete
with any errors?

bb
--
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 (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #2  
Old   
bingo bob
 
Posts: n/a

Default Re: how to handle my comment validation errors - 11-06-2009 , 05:52 AM






Basically you can see what I followed here.

http://skionrails.wordpress.com/tutorials/how-to-write-a-blog-in-15-minutes/

My comments on my resorts in this case are similar to the comments on
each blog post.

But when this guy redirects back to the @post I can't see how validation
errors can be included?
He just uses the flash?

Please advise.

Thanks

Ruert
--
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 (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #3  
Old   
bingo bob
 
Posts: n/a

Default Re: how to handle my comment validation errors - 11-06-2009 , 06:56 AM



Here's my existing comments controller create action...

def create
@resort = Resort.find(params[:resort_id])
@comment = Comment.new(params[:comment])
@comment.resort = @resort
if @comment.save
flash[:notice] = "Successfully created comment, it'll be cleared
and show up soon on this page."
else
flash[:notice] = "Something went wrong creating your comment."
end
redirect_to @resort
end


As you can see, as it stands the second to last line just redirects.

--
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 (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #4  
Old   
mike
 
Posts: n/a

Default Re: how to handle my comment validation errors - 11-07-2009 , 12:05 PM



Either you render the resort show action if your create fails or you
use ajax to update only the comment part of your view.

2009/11/6, bingo bob <rails-mailing-list (AT) andreas-s (DOT) net>:
Quote:
I've got a resorts view, shows details of a ski resort. Under the resort
description I allow users to leave comments on the resort - works fine.

- Resort has many comments.
- Comment belongs to resort.

However, slight problemo - the comment form on my resorts page creates a
new comment via the Comments Controller (new and create actions are
available to the public). This works fine.

But how oh how do I send back the comment validation errors to the
Resorts show view when redirected from the comments controller - I'd
like to do this.

It's horrible at the moment - I'm using the flash to display feedback to
the user, it's not ideal.

How should I handle this - surely a common situation?

When I redirect back to the resort can I pass back the comment complete
with any errors?

bb
--
Posted via http://www.ruby-forum.com/.



--
Von meinen Mobilgerät aus gesendet

--~--~---------~--~----~------------~-------~--~----~
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 (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.