Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Last active December 21, 2015 08:09
Show Gist options
  • Save telagraphic/6275965 to your computer and use it in GitHub Desktop.
Save telagraphic/6275965 to your computer and use it in GitHub Desktop.
Started POST "/posts" for 127.0.0.1 at 2013-08-19 21:18:10 -0400
Processing by PostsController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"kTZyYTox6CM5xEGK1xAs4qLmA++WB4ZACedzI6inhPQ=", "post"=>{"title"=>"test", "comment"=>"test", "email"=>""}, "commit"=>"Submit"}
 (0.1ms) BEGIN
SQL (6.3ms) INSERT INTO "posts" ("comment", "created_at", "email", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["comment", "test"], ["created_at", Tue, 20 Aug 2013 01:18:10 UTC +00:00], ["email", ""], ["title", "test"], ["updated_at", Tue, 20 Aug 2013 01:18:10 UTC +00:00]]
 (0.5ms) COMMIT
Rendered posts/create.js.erb (29.5ms)
Completed 500 Internal Server Error in 42ms
ActionView::Template::Error (Missing partial posts/post with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
* "/Users/telagraphic/Documents/programming/rails/ohfu/app/views"
):
1: $("#posts-list").append('<%= j render(@post) %>');
2: $('#post-title, #post-comment, #post-name').val("");
app/views/posts/create.js.erb:1:in `_app_views_posts_create_js_erb___3164016242032260488_70362267032660'
app/controllers/posts_controller.rb:6:in `create'
Rendered /Users/telagraphic/.rvm/gems/ruby-1.9.3-p327@ohfu-gem-set/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /Users/telagraphic/.rvm/gems/ruby-1.9.3-p327@ohfu-gem-set/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.1ms)
Rendered /Users/telagraphic/.rvm/gems/ruby-1.9.3-p327@ohfu-gem-set/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (11.0ms)
Started POST "/posts" for 127.0.0.1 at 2013-08-19 21:18:10 -0400
Processing by PostsController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"kTZyYTox6CM5xEGK1xAs4qLmA++WB4ZACedzI6inhPQ=", "post"=>{"title"=>"test", "comment"=>"test", "email"=>""}, "commit"=>"Submit"}
 (0.1ms) BEGIN
SQL (0.5ms) INSERT INTO "posts" ("comment", "created_at", "email", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["comment", "test"], ["created_at", Tue, 20 Aug 2013 01:18:10 UTC +00:00], ["email", ""], ["title", "test"], ["updated_at", Tue, 20 Aug 2013 01:18:10 UTC +00:00]]
 (0.5ms) COMMIT
Rendered posts/create.js.erb (1.4ms)
Completed 500 Internal Server Error in 8ms
ActionView::Template::Error (Missing partial posts/post with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
* "/Users/telagraphic/Documents/programming/rails/ohfu/app/views"
):
1: $("#posts-list").append('<%= j render(@post) %>');
2: $('#post-title, #post-comment, #post-name').val("");
app/views/posts/create.js.erb:1:in `_app_views_posts_create_js_erb___3164016242032260488_70362267032660'
app/controllers/posts_controller.rb:6:in `create'
NoMethodError in Posts#create
Showing /Users/telagraphic/Documents/programming/rails/ohfu/app/views/posts/_post.html.erb where line #2 raised:
undefined method `each' for nil:NilClass
Extracted source (around line #2):
1: <ul id="posts-list">2: <% @posts.each do |post| %>3: <li>4: <div>5: <% if post.persisted? %>
Trace of template inclusion: app/views/posts/create.js.erb
Rails.root: /Users/telagraphic/Documents/programming/rails/ohfu
Application Trace | Framework Trace | Full Trace
app/views/posts/_post.html.erb:2:in `_app_views_posts__post_html_erb___2584183490202323164_70310670283120'app/views/posts/create.js.erb:1:in `_app_views_posts_create_js_erb___3514158357758799413_70310670241600'app/controllers/posts_controller.rb:11:in `create'
Request
Parameters:
{"utf8"=>"✓", "authenticity_token"=>"kTZyYTox6CM5xEGK1xAs4qLmA++WB4ZACedzI6inhPQ=", "post"=>{"title"=>"i hate it", "comment"=>"when people yell", "email"=>""}, "commit"=>"Submit"}
<ul id="posts-list">
<% @posts.each do |post| %>
<li>
<div>
<% if post.persisted? %>
<h3><%= link_to post.title, post %></h3>
<% end %>
</div>
</li>
<% end %>
</ul>
<%= form_for @post, remote: true do |post| %>
<div class="form-group">
<label for="post-title">Title</label>
<%= post.text_field :title, :class => 'form-control', :id => 'post-title' %>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Buckeye fans are...</label>
<%= post.text_area :comment, :class => 'form-control', :id => 'post-comment' %>
</div>
<div class="form-group">
<label for="name">Name</label>
<%= post.text_field :email, :class => 'form-control', :id => 'post-name' %>
</div>
<%= post.submit 'Submit', :class => 'btn btn-danger' %>
<% end %>
$("#posts-list").append('<%= j render(@post) %>');
$('#post-title, #post-comment, #post-name').val("");
<div class="row">
<div class="col-md-6">
<h1>Offenders</h1>
<%= render 'posts/post_form' %>
</div>
</div>
<div class="row" id="offender-posts">
<div class="col-md-6">
<%= render 'posts/post' %>
</div>
</div>
class PostsController < ApplicationController
def create
@post = Post.new(params[:post])
if @post.save
respond_to do |format|
format.html { redirect_to posts_path }
format.js
end
else
render 'index'
end
end
def index
@post = Post.new
@posts = Post.all
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment