Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/controllers/favorites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ def index
end

def show
favorite = Favorite.find(params[:id])
favorite = Favorite.find(params["id"])
render json: favorite
end

def create
favorite = Favorite.create(user_id: params[:user_id], mural_id: params[:mural_id])
puts params
puts '======================'
favorite = Favorite.create(user_id: params[:user]["id"], mural_id: params[:mural]["id"])
render json: favorite
end


# will eventuall need a create so i can create a favotire
def destroy
Favorite.destroy(params[:id])
end

end
16 changes: 15 additions & 1 deletion app/controllers/murals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ def show
render json: mural
end

def new
def create

mural = Mural.create(mural_title: params[:mural_title], year_installed: params[:year_installed], description: params[:description], artists: params[:artists])

render json: mural

end

def update
puts "***********-----------------***************"
mural = Mural.find(params[:id])
mural.update(mural_title: params[:mural_title], year_installed: params[:year_installed], description: params[:description], artists: params[:artists] )

render json: mural
end


end
19 changes: 17 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,25 @@ def create
end
end



def update
puts "-------------------------------------"
user= User.find(params[:id])
if user.update(user_params)
render json: user
else
render json: {error: "Failed"}
end
end




end

private
def user_params
params.require(:user).permit(:first_name, :last_name, :user_name)
# , favorite_murals: [:id, :artist_id, :mural_title, :year_installed, :description, :artists, :created_at, :updated_at]

end

3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ class User < ApplicationRecord
has_secure_password
validates :user_name, uniqueness: { case_sensitive: false }

# accepts_nested_attributes_for :favorite_murals


# I need to research about uniqueness...what is current is for testing
end
11 changes: 11 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_04_01_161308) do

Expand Down