I have a Product.rb model in my Rails app, and it has a :title attribute and a :price attribute. From the Rails console I can successfully create an instance of one of these models, but I'm having trouble passing values for the :title and :price. Here's my products_controller:
class ProductsController < ApplicationController
def create
@product = Product.create(
:name = params[:name],
:price = params[:price]
)
end
end
This is the command I use to create an instance:
Product.create("name", 123)
The :name attribute is set to be text and the :price attribute to be an integer. But when I hit enter this is what I got:
ArgumentError: wrong number of arguments (2 for 0..1)
I haven't written any Rails since before v4 and I'm a bit rusty. Anyone know the problem?
:name => params[:name]etc, arrow, not assignment.