Note that there are some explanatory texts on larger screens.

plurals
  1. PONoMethodError in BlogsController#create
    primarykey
    data
    text
    <p>I've spent the last three hours trying to find a solution to this and checked everything I could find here on StackOverflow but no go. </p> <p>I am specifically getting this error: <code>"undefined method</code>[]' for nil:NilClass"`</p> <p>And the application trace gives me this: <code>app/controllers/blogs_controller.rb:7:in</code>create'`</p> <p>I think it has something to do with how I am passing the params but I can't figure out what's wrong. Here's my Controller code:</p> <pre><code>class BlogsController &lt; ApplicationController def index @blogs = Blog.all end def new @blog_entry = Blog.new end def create Blog.create(title: params[:blogs][:title], content: params[:blogs][:content]) redirect_to action: 'index' end end </code></pre> <p>Here's my new.html.erb file:</p> <pre><code>&lt;%= form_for @blog_entry, as: :post, url: {action: "create"} do |f| %&gt; Title: &lt;/br&gt; &lt;%= f.text_field :title %&gt; &lt;br /&gt; Content: &lt;br /&gt; &lt;%= f.text_area :content %&gt; &lt;br /&gt; &lt;%= f.submit "Publish", class: "btn btn-primary" %&gt; &lt;br /&gt; &lt;% end %&gt; </code></pre> <p>Here's the relevant log file:</p> <pre><code>Started POST "/blogs" for 127.0.0.1 at 2013-06-12 21:54:48 -0700 Processing by BlogsController#create as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"cSGH7PgbbFHSSEPV3pJ2LP6V1GvUN10RHRfUDTUXou4=", "post"=&gt;{"title"=&gt;"first entry 5", "content"=&gt;"new entry"}, "commit"=&gt;"Publish"} [1m[35m (0.1ms)[0m begin transaction [1m[36mSQL (0.5ms)[0m [1mINSERT INTO "blogs" ("content", "created_at", "title", "updated_at") VALUES (?, ?, ?, ?)[0m [["content", nil], ["created_at", Thu, 13 Jun 2013 04:54:48 UTC +00:00], ["title", nil], ["updated_at", Thu, 13 Jun 2013 04:54:48 UTC +00:00]] [1m[35m (3.2ms)[0m commit transaction Redirected to http://localhost:3000/blogs Completed 302 Found in 5ms (ActiveRecord: 3.7ms) </code></pre> <p>Hopefully someone has an idea. Please?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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