# See if the product exists
begin
#This throws a method not found error for where
product = Product.where({ :name => name }).first
rescue
Product.new
# This throws a method not found error for request_id
product.request_id = request.id
product.save
end

I'm trying to create a new product object like so
product = Product.first(:conditions => { :name => name })

When I call that I get an error saying undefined method 'first' for Product:Class
I tried doing Product.new and I can't access any attributes. I get this for every one undefined method 'request_id=' for #<Product:0x007ffce89aa7f8>

I've been able to save request objects. What am I doing wrong with products?

EDIT:

So as it turns out there was an old Product data type that was being imported that wasn't an ActiveRecord class. It was using that instead of my Product::ActiveRecord. I deleted that import and it's good to go. Sorry to have wasted everybody's time.

Not sure what the proper protocol is here for what to do with this question.

You said you're trying to "create a new product" but you're calling .first which is for selecting a Product. If you're trying to initialize a new Product with a given name, you should use the following: product = Product.new(:name => name)
–
Shane AndradeFeb 26 '13 at 1:52

I'm trying to create a new product (empty) with Product.new. That's not working. I tried the Product.where and got this undefined method `where' for Product:Class
–
btateFeb 26 '13 at 1:57

If you are missing any attributes run another migration to add them to the Product table.

If none of those suggestions work, check to make sure that there isn't an existing class with the same name in your project. This would cause all kinds of errors and would explain certain methods not being found.

The console dumps out the Product model fine. If I try to pass any parameters to Product.new I get this wrong number of arguments(1 for 0)
–
btateFeb 26 '13 at 3:08

Can you print out exactly what you are doing from the console?
–
tomcioppFeb 26 '13 at 3:10

I was running the product creation code in the controller. I can create and save a product in the console using the exact code I'm using in the controller. But in the controller I get an error every time I try to do anything with the Product class.
–
btateFeb 26 '13 at 3:23

Could you please post the code that you have in your controller.
–
tomcioppFeb 26 '13 at 3:32