Note: Rails newb here.
So, I recently created a Rails app with mongoid
gem for use of MongoDB. I have a namespace route of :blog
with a nest of resource of posts
Routes.rb:
Rails.application.routes.draw do
namespace :blog do
resources :posts
end
end
The error comes from app/controllers/blog/posts_controller.rb:
Class Blog::PostsController < ApplicationController
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post
else
render 'new'
end
end
private
def post_params
params.require(:post).permit(:title, :body)
end
end
I also have a 'post' model that comes with a title and body:
Class Post
include Mongoid::Document
field :title, type: String
field :body, type: String
end
In new.html.erb:
<h1>Rails Sample Blog</h1>
<%= form_for @post, url: blog_post_path do |f| %>
<div><%= f.label :title %><%= f.text_field :title %></div>
<div><%= f.label :body %><%= f.text_area :body %></div>
<% end %>
Is there something I left out that I didn't catch? It's slowly haunting me.
Edit: See this Git repo: https://github.com/hackathons-com/Rails-MongoDB-Devise-test
Edit 2:
undefined method `post_url' for #<Blog::PostsController:0x007f3d19105ee8>