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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:09:13+00:00 2026-06-18T11:09:13+00:00

In my app, I have created a form to create new posts (Post is

  • 0

In my app, I have created a form to create new posts (Post is a model). I have a controller with the name posts. The form is located in the admins controller. The form use the form_for(@post). It post to the post controller. In this method, the post gets created successfully. But the problem is with failed submissions. In the form, I have added the code to show the errors

    <% if @post.errors.any? %>
        <div id="error_explanation">
            <div class="alert alert-error">
                The form contains <%= pluralize(@post.errors.count, "error") %>
            </div>
            <ul>
                <% @post.errors.full_messages.each do |msg| %>
                    <li> <%= msg %> </li>
                <% end %>
            </ul>
        </div>
    <% end %>

But in the post controller, if there’s a failed submission, I have set it to redirect_to the newpost page in the admins controller. When redirecting, I will loose the error messages.

So, I added

render 'dasharea/newpost'

localhost:3000/dasharea/newpost is the URL of the page that have the form. With this code, it say

Missing template dasharea/newpost with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.

But Im already in that page? Then I tried to add the controller and the action like this (note: im editing the create action of posts controller. I need to render the newpost action in admins controller) :

render 'admins/newpost'

Then, it will direct me to the posts :

http://localhost:3000/posts

But now, the form is there and I can see the errors. But I need to render the oroginal page which I have the form (dasharea/newpost)! How can I do this? What have I done wrong?

  • 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-18T11:09:15+00:00Added an answer on June 18, 2026 at 11:09 am

    My solution: AJAX form. No more issues. Update the form on the spot with javascript. You can even redirect using window.location.href = '/your-url' if needed.

    If you need to handle html requests, you could always point your form to the url of your choice:

    form_for @post, url: route_to_current_controller
    

    Handle the create_post action on this controller and make sure your routes are set properly. The bad side of it is that you’ll be handling posts creation in a different controller than your PostsController.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Rails 3.2 project, I have a form to create a new post
In my Rails 3.2 project, I have a form to create a new post
I have created a simple web app/form using google app engine. the site is
I've created an app which contains form and that have to filled up in
I have an express app that I want to use the connect-form module on
I am trying to create form that contains another model in rails. I have
I have a Post model in my app, which belongs_to a User model, as
I have an model called Purchase.rb. each purchase is created through a form as
I have a namespaced controller for some admin functionality. My create form does not
In my android app I have created a raw folder inside /res folder (/res/raw).

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.