How can I render a show action on certain conditions?
def show
@post = Post.find_approved
if @post.approved
approved = true
end
respond_to do |format|
# I only want to render show.html.erb if approved is true if not I
would like to redirect the user back to where he came from
end
end
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
badnaam wrote:> How can I render a show action on certain conditions? > > def show > @post = Post.find_approved > if @post.approved > approved = true > end > respond_to do |format| > # I only want to render show.html.erb if approved is true if not I > would like to redirect the user back to where he came from > end > endYou could do a respond_to do |format| if approved format.html end end Is that what you are expecting? -- Raja -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.