ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Unresolved issue #275

Closed adriennedao closed 7 years ago

adriennedao commented 7 years ago

To Jesse: still unable to create the new recipe after having updated info on the def method. Error appeared again as "can't write unknown attribute user_id".

jshawl commented 7 years ago

what is the contents of db/schema.rb?

adriennedao commented 7 years ago

create_table "recipes", force: :cascade do |t| t.string "name" t.string "img_url" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "user_id" t.index ["user_id"], name: "index_recipes_on_user_id", using: :btree end

jshawl commented 7 years ago

hmm that looks right. and can i see recipes controller create action?

adriennedao commented 7 years ago

create_table "users", force: :cascade do |t| t.string "username" t.string "password" end

add_foreign_key "ingredients", "recipes" add_foreign_key "recipes", "users" end

adriennedao commented 7 years ago

def create @recipe = Recipe.create!(recipe_params.merge(user: @current_user)) redirect_to @recipe en

jshawl commented 7 years ago

hmm maybe try stopping and restarting your rails server? everything looks right to me...

adriennedao commented 7 years ago

Still not working. Restarted the server.

jshawl commented 7 years ago

ok let's try to narrow this down to either a database issue or a controller issue.

in db/seeds.rb can you add:

Recipe.create!(name:'my recipe', user: User.last)

and try seeding - any errors?