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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:42:03+00:00 2026-06-08T04:42:03+00:00

I have list with posts (pages#home), on click I open list with comments (posts#show),

  • 0

I have list with posts (pages#home), on click I open list with comments (posts#show), where I declare variable @feed_items. In the end of the comments I have simple_form for new comment (comments#create). Problem: if error occuring on submit button, I need to render existed list with comments and form with errors.
I’m trying in comments#create:

if @comment.save
  ...
else
  render 'posts/show'
end

but in this case variable @feed_items isn’t declared because method posts#show didn’t called. When I trying to write redirect_to I see list with comments but without error messages. How to do this?

  • 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-06-08T04:42:05+00:00Added an answer on June 8, 2026 at 4:42 am

    This is a common mistake people do. The render method only selects the view to display, and the redirect_to method executes the action of the redirection again.
    When there are errors, you call the render method to select the view you want to display, and you have to manually assign all the instance variables this view need to work out.
    Check Section 2.3.2 from the rails guides: http://guides.rubyonrails.org/layouts_and_rendering.html

    In your case it would be something like this:

    if @comment.save
      ...
    else
      # Populate the @feed_items in here again
      render 'posts/show'
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a list of posts. i want print some words of post content
I have read the other posts, e.g., vim: Executing a list of editor commands
So what i have in mind is showing a list with most popular posts
My Situation I have a list of items(surveys) displayed on my home page. When
I have an unordered list: <ul> <li>Home</li> <li>Products</li> <ul> <li>Fruit</li> <li>Veg</li> <li>Frozen</li> </ul> <li>Services</li>
I need a jQuery list like in Twitter's home page. This means, to have
I have a dynamic list of items that will be used to POST information
I have list of input area in the form with id like contact1_title, contact2_title,
I have list of articles on the page in table and i want to
I have list of structure. I want to modify a particular data from 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.