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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:27:19+00:00 2026-05-15T21:27:19+00:00

Just tried writing a simple validates_presence_of in my model, and when the errors try

  • 0

Just tried writing a simple validates_presence_of in my model, and when the errors try to render, it calls this :

Template is missing

Missing template posts/create with {:locale=>[:en, :en], :handlers=>[:builder, :rjs, :erb, :rhtml, :rxml, :haml], :formats=>[:html]} in view paths "/Users/johnsmith/Sites/shwagr/app/views"

Errors don’t have seperate views in Rails3 do they? I thought that was Rails magic..

Curious if anyone had this problem, or knew how to make it correctly validate.

My Model:

validates_presence_of :category, :name, :url

My Controller:

def new
  @post = Post.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @post }
  end
end


def create
  @post = Post.new(params[:post])
  if @post.valid? && current_user.posts << @post
    respond_to do |format|
      if @post.save
        format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
        format.xml  { render :xml => @post, :status => :created, :location => @post }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
      end
    end
  end
end

Update

Interesting, I ‘touch app/views/posts/create.html.haml’, and now it removed the error and instead loads that page instead. But why would it? Or more importantly, how can I make it just redirect back to the new_post_path(@post) like it should?

  • 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-05-15T21:27:19+00:00Added an answer on May 15, 2026 at 9:27 pm

    If your

    if @post.valid? && current_user.posts << @post
    

    line returns false, no render() or redirect_to() is called. Rails’ default behavior then is to render the view with the same name as your method. That would be create.BUILDER.FORMAT.

    Try to remove the line. Use this code instead:

    @post = current_user.posts.new(params[:post])
    respond_to do |format|
      if @post.save
        ...
    

    Or write an else case with

    render :action => "new"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just tried the tooltip like this Easy image preview ... But i cant
I'm just getting started with Objective-C and I'm writing a simple application. I made
I'm thinking about writing a simple UI designer in Java. I'm just playing with
I am writing a simple HashString class, which is just a string and its
I'm just writing an simple method witch reading data from a general stream -
I'm writing a simple winforms app in C#. I create a worker thread and
I've just finished reading 'Java for Dummies' and have begun to create a simple
I'm practising with C, writing simple programs. The little program below should just get
Just tried to execute a small Lua script, but unfortunately I'm doing something wrong.
Just tried some small graphics application of mine on Windows 7, and I'm getting

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.