Update parties_controller.rb
Finding parties based on shortcode, and saving parties with user ID where available
This commit is contained in:
parent
cb499a68ac
commit
975dd39ec8
1 changed files with 7 additions and 2 deletions
|
|
@ -6,11 +6,12 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@party = Party.new(shortcode: random_string)
|
@party = Party.new(shortcode: random_string, user_id: party_params[:user_id])
|
||||||
render :show, status: :created if @party.save!
|
render :show, status: :created if @party.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
render_not_found_response if @party.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
@ -28,6 +29,10 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set
|
def set
|
||||||
@party = Party.find("abc")
|
@party = Party.where("shortcode = ?", params[:id]).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def party_params
|
||||||
|
params.require(:party).permit(:user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
Reference in a new issue