Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing templates from new Rails 3 app?
    text
    copied!<p>Just tried writing a simple validates_presence_of in my model, and when the errors try to render, it calls this :</p> <pre><code>Template is missing Missing template posts/create with {:locale=&gt;[:en, :en], :handlers=&gt;[:builder, :rjs, :erb, :rhtml, :rxml, :haml], :formats=&gt;[:html]} in view paths "/Users/johnsmith/Sites/shwagr/app/views" </code></pre> <p>Errors don't have seperate views in Rails3 do they? I thought that was Rails magic..</p> <p>Curious if anyone had this problem, or knew how to make it correctly validate.</p> <p>My Model:</p> <pre><code>validates_presence_of :category, :name, :url </code></pre> <p>My Controller:</p> <pre><code>def new @post = Post.new respond_to do |format| format.html # new.html.erb format.xml { render :xml =&gt; @post } end end def create @post = Post.new(params[:post]) if @post.valid? &amp;&amp; current_user.posts &lt;&lt; @post respond_to do |format| if @post.save format.html { redirect_to(@post, :notice =&gt; 'Post was successfully created.') } format.xml { render :xml =&gt; @post, :status =&gt; :created, :location =&gt; @post } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @post.errors, :status =&gt; :unprocessable_entity } end end end end </code></pre> <p><b>Update</b></p> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload