NoMethodError

I’m trying to create an “Inventory” application that has two models:

1- item
2- itemdetails

I have made a “relationship” between those two models, such that:

item has_many itemdetails

Once I try to create an item or itemdetail I get a NoMethodError as
follows: http://pastie.org/private/wvqtorzl12vrkrudzc8ha

This also applies if I wnt to “show”.

The weird thing aslo is that when I get the NoMethodError page after I
add an item gets created, I find that I get a message that the item hs
been cteated succssfully.

And, attached are the files to show what I hav e did?

Any ideas on this?

Thanks a lot.

On Fri, Jul 16, 2010 at 1:08 PM, Abder-Rahman A. [email protected]
wrote:

follows: http://pastie.org/private/wvqtorzl12vrkrudzc8ha

Have you run all your migrations? Do you have the price column in your
itemdetails table?


Leonardo M…
There’s no place like ~

Leonardo M. wrote:

On Fri, Jul 16, 2010 at 1:08 PM, Abder-Rahman A. [email protected]
wrote:

follows: http://pastie.org/private/wvqtorzl12vrkrudzc8ha

Have you run all your migrations? Do you have the price column in your
itemdetails table?


Leonardo M…
There’s no place like ~

Thanks Leonardo.

I have included “price” when generating the scaffold. When I checked the
“itemdetails” table using SQLite Manager, the price in addition to other
fields are not presented as columns, but, there is ONE column presented
:expressionless:

You can even see the fields presented in the show.html.erb og itemdetail
attached.

I also made a rake db:migrate

Why aren’t those fields present in the table?

What do you think I should do now?

Thanks.

Does sequence have to do here?

I mean, if I create the scaffold “item”, must I IMMEDIATELY rake
db:migrate BEFORE creating the scaffold “itemdetails”?

In my tables, I can see that the “items” table has the required fields,
but “itemdetails”. You know the story :slight_smile:

Thanks.

On Fri, Jul 16, 2010 at 1:35 PM, Abder-Rahman A. [email protected]
wrote:

Does sequence have to do here?

I mean, if I create the scaffold “item”, must I IMMEDIATELY rake
db:migrate BEFORE creating the scaffold “itemdetails”?
No, no need to.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Leonardo M…
There’s no place like ~

On Fri, Jul 16, 2010 at 1:31 PM, Abder-Rahman A. [email protected]
wrote:

Leonardo M…
attached.

I also made a rake db:migrate

Why aren’t those fields present in the table?
Maybe there was something wrong with your migration generated file

What do you think I should do now?
Check the migration file created for the itemdetails scaffold, fix it
and re-do that migration with rake db:migrate:redo
VERSION=YOUR_MIGRATION_VERSION_NUMBER_HERE

If you want to start fresh, just re-create the scaffold and make sure
all the fields are created properly.
You can also generate a new migration to add the missing fields to
this table, but I wouldn’t recommend this for clarity sake.

Hope it helps.


Leonardo M…
There’s no place like ~

Thanks Leonardo. Just a small question since I’m nearly new to Rails.
What is the “migration file” called?

Leonardo M. wrote:

On Fri, Jul 16, 2010 at 1:35 PM, Abder-Rahman A. [email protected]
wrote:

Does sequence have to do here?

I mean, if I create the scaffold “item”, must I IMMEDIATELY rake
db:migrate BEFORE creating the scaffold “itemdetails”?
No, no need to.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Leonardo M…
There’s no place like ~

Leonardo. Seems I may go with creating it from scratch again. But, till
now, don’t know what I have been missing for a column to show up and
other not. :expressionless:

Thanks.

On Sat, Jul 17, 2010 at 12:36 PM, Abder-Rahman A.
[email protected] wrote:

I think I figured what the issue was. I was assigning the type “double”
instead of writing it as “decimal” :slight_smile:

WAS —> price:double
NOW —> price:decimal —> Worked
There you go.
Sorry for the late.
To find the migration files you should look at the db/migrate
directory, there you’ll find those files named with the version number
(which is actually a timestamp) , followed by a relevant name about
what they do.
For example, your itemdetails scaffold migration file, might be named
something like this:
20100717192542_create_itemdetails.rb

Hope it helps.

Cheers.

Leonardo M…
There’s no place like ~

Thanks a lot.

I think I figured what the issue was. I was assigning the type “double”
instead of writing it as “decimal” :slight_smile:

WAS —> price:double
NOW —> price:decimal —> Worked

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs