Form_for() question

Well right now i’m currently trying to make a form that posts
information into my database. I’m using the form_for function, but
when i run the server and go to the page and get this error:

undefined method `posts_path’ for #ActionView::Base:0x23bbabc

So i have no idea what i’m doing wrong, here is the code for the form:

<% form_for(@posts) do |p| %>
<%= p.error_message %>

<%= p.label :title %>
<%= p.text_field :title %>

<%= p.label :post %>
<%= p.text_area :post %>

<%= p.submit "Submit Post" %>

<% end %>

Any idea?

Zack K. wrote:

Well right now i’m currently trying to make a form that posts
information into my database. I’m using the form_for function, but
when i run the server and go to the page and get this error:

undefined method `posts_path’ for #ActionView::Base:0x23bbabc

You have no route for posts declared.

How do i set the route?
Sorry, i’m new to Rails

Zack K. wrote:

How do i set the route?
Sorry, i’m new to Rails

You can only use named routes (which form_for uses when you pass it an
AR object) if you declare them. This is done with the map.resource and
map.resources methods in your config/routes.rb file. Read up on named
routes.

Well now i have it working so i don’t get an error, but it doesn’t
submit the information into the server.

What do you have in your posts_controller?