bfellerath / RESTaurant

RESTaurant app project
0 stars 0 forks source link

Trying to update food_items, having trouble with the route. #3

Closed bfellerath closed 9 years ago

bfellerath commented 9 years ago

Writing the following code:

    #--- UPDATE FOOD ITEMS: update --
  put '/:id' do
    food_item = FoodItem.find(params[:id])
    food_item.update(params["name"])
    redirect "/food_items/#{food_item.id}"

  end

Getting this error: When assigning attributes, you must pass a hash as an argument.

emilylordahl commented 9 years ago

Taking a look now. Can you push so I can check out your edit food items view?

emilylordahl commented 9 years ago

But at first glance, I believe the params with which you are trying to update are a little off. Do you want to update the params for the food_item?

emilylordahl commented 9 years ago

...like so:

food_item.update(params[:food_item])

bfellerath commented 9 years ago

I have it working now

emilylordahl commented 9 years ago

:ok_hand::ok_hand::ok_hand::ok_hand::ok_hand::ok_hand: