Undefined method `posts_path'

On Mon, May 23, 2011 at 6:54 AM, Colin L. [email protected]
wrote:

wrote:

the code by hand.

  1. Look up the database table for posts, and see if you have a
    that you are using). railstutorial.org is a good free to use online
    from the fact that the posts table will contain a column ‘name’.
    “rake db:migrate” but still the same error persists.I think now it might
    work,but it did not.

Have you worked right through railstutorial.org already?
No.I followed yet it from Agile web development with Rails (Pdf).Does
everything seems right with coding part?

John

On 23 May 2011 15:37, john shelfer [email protected] wrote:

No.I followed yet it from Agile web development with Rails (Pdf).Does
everything seems right with coding part?

It looks ok. Can you post your models/post.rb file, the error message
you are getting, the stack trace, and the relevant section of code
where the error is generated (I know you have posted this previously
but copy it and paste it again just so we have everything together).
Tell us which line in the source is the one referred to in the error.
Copy from your actual files so we make sure there are no typos. If
while doing this you realise that the error is not actually the same
one you were getting previously then try to work it out before
posting.

Also check that the database does now actually contain the posts table
with the correct columns.

Colin

On Mon, May 23, 2011 at 3:04 AM, Colin L. [email protected]
wrote:

In ‘posts’ table there is no column for name,title and content.

I suggested before reading the Rails Guide on Routing. I also suggest
that you read the Getting Started guide and then the others. Also
work through a good tutorial (make sure it is for the version of Rails
that you are using). railstutorial.org is a good free to use online
tutorial.

      Thank you very much.I will read it now.

The reason is that you are missing some fundamental
understanding of how Rails works. When you do form_for(@post) and
then f.text_field :name rails expects @post to have a method ‘name’ to
get the initial value for display. Often this will come automatically
from the fact that the posts table will contain a column ‘name’.
Since you have no such column it complains that Post has no method

  Because i am not doing scaffold,so can i add column values
  manually to table 'posts' OR changes should be made in
  Model.

  John

John

On Mon, May 23, 2011 at 10:50 AM, Colin L. [email protected]
wrote:

On 23 May 2011 15:37, john shelfer [email protected] wrote:

No.I followed yet it from Agile web development with Rails (Pdf).Does
everything seems right with coding part?

It looks ok. Can you post your models/post.rb file,

   model/post.rb file looks like:
  class Post < ActiveRecord::Base
   end

the error message

you are getting, the stack trace, and the relevant section of code
where the error is generated

(I know you have posted this previously
but copy it and paste it again just so we have everything together).
Tell us which line in the source is the one referred to in the error.

 In /app/view/try.htm..erb file generate error at line number 8
  which is
  <%= f.text_field :name %>

Copy from your actual files so we make sure there are no typos. If
while doing this you realise that the error is not actually the same
one you were getting previously then try to work it out before
posting.

Also check that the database does now actually contain the posts table
with the correct columns.

Posts table exist in database but there is no column for name,title
and content even after "rake db:migrate",it couldn't generate.

  John

On Mon, May 23, 2011 at 8:06 AM, john shelfer [email protected]
wrote:

Also check that the database does now actually contain the posts table
with the correct columns.

Posts table exist in database but there is no column for name,title
and content even after “rake db:migrate”,it couldn’t generate.

If your migration didn’t run, then how do you expect this to work any
better than before?

And your previously posted migration code was trying to create a
table that apparently already exists, which is pretty much guaranteed
to fail :slight_smile:

You might want to read up on migrations at this point…

FWIW,

Hassan S. ------------------------ [email protected]

twitter: @hassan

On May 23, 11:33am, Hassan S. [email protected]
wrote:

And your previously posted migration code was trying to create a
table that apparently already exists, which is pretty much guaranteed
to fail :slight_smile:

You might want to read up on migrations at this point…
I checked out this and it seems ok with my migration coding part

Active Record Migrations — Ruby on Rails Guides

John

On May 23, 11:33am, Hassan S. [email protected]
wrote:

On Mon, May 23, 2011 at 8:06 AM, john shelfer [email protected] wrote:

Also check that the database does now actually contain the posts table
with the correct columns.

Posts table exist in database but there is no column for name,title
and content even after “rake db:migrate”,it couldn’t generate.

If your migration didn’t run, then how do you expect this to work any
better than before?
But to run a migration “rake db:migrate” is right command ,still
it
didn’t run .why?
And your previously posted migration code was trying to create a
table that apparently already exists, which is pretty much guaranteed
to fail :slight_smile:

Yes table already exist but migration didn’t run so columns are not
added in table.

John

On Mon, May 23, 2011 at 8:17 PM, John shelfer [email protected]
wrote:

But to run a migration “rake db:migrate” is right command ,still
it didn’t run .why?

That’s what error messages tell you. But you have to read them.


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Mon, May 23, 2011 at 11:32 PM, Hassan S. <
[email protected]> wrote:

On Mon, May 23, 2011 at 8:17 PM, John shelfer [email protected]
wrote:

But to run a migration “rake db:migrate” is right command ,still
it didn’t run .why?

That’s what error messages tell you. But you have to read them.

On Tue, May 24, 2011 at 1:58 AM, john shelfer
[email protected]wrote: