From 57ae3dbe4adead688924ea34cc7d7183fff80b75 Mon Sep 17 00:00:00 2001
From: Lucas Videla
Date: Wed, 2 Oct 2019 12:45:05 -0300
Subject: [PATCH] Fixed issue #47
---
app/controllers/api/v1/talks_controller.rb | 2 +-
app/javascript/components/Conference.vue | 4 ++--
app/javascript/components/Speaker.vue | 4 ++--
app/javascript/components/Talk.vue | 7 ++++---
app/javascript/router.js | 2 +-
config/routes.rb | 5 +++--
6 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/app/controllers/api/v1/talks_controller.rb b/app/controllers/api/v1/talks_controller.rb
index 4d30897..2efffb7 100644
--- a/app/controllers/api/v1/talks_controller.rb
+++ b/app/controllers/api/v1/talks_controller.rb
@@ -5,7 +5,7 @@ class TalksController < ApplicationController
respond_to :json
def show
- talk = Talk.find_by(slug: params[:slug])
+ talk = Talk.joins(:conference).where(conferences: {slug: params[:conference_slug]}).find_by(slug: params[:slug])
x = {
title: talk.title,
slug: talk.slug,
diff --git a/app/javascript/components/Conference.vue b/app/javascript/components/Conference.vue
index 43ca717..442b5f6 100644
--- a/app/javascript/components/Conference.vue
+++ b/app/javascript/components/Conference.vue
@@ -50,7 +50,7 @@
-
+
@@ -78,7 +78,7 @@
>{{ speaker.name }}
- {{ talk.title }}
+ {{ talk.title }}
diff --git a/app/javascript/components/Speaker.vue b/app/javascript/components/Speaker.vue
index 8b76fce..0236bf7 100644
--- a/app/javascript/components/Speaker.vue
+++ b/app/javascript/components/Speaker.vue
@@ -19,7 +19,7 @@
-
+
@@ -41,7 +41,7 @@
>{{ talk.conference.title }}
- {{ talk.title }}
+ {{ talk.title }}
diff --git a/app/javascript/components/Talk.vue b/app/javascript/components/Talk.vue
index ae330e3..c89cb3a 100644
--- a/app/javascript/components/Talk.vue
+++ b/app/javascript/components/Talk.vue
@@ -60,10 +60,11 @@ export default {
};
},
created() {
- var slug = this.$route.params.slug;
- axios.get("/api/v1/talks/" + slug).then(response => {
- this.talk = response.data;
+ var conference_slug = this.$route.params.conference_slug;
+ var talk_slug = this.$route.params.talk_slug;
+ axios.get("/api/v1/conferences/" + conference_slug + "/talks/" + talk_slug).then(response => {
+ this.talk = response.data;
setTimeout(function(){
new Carousel({
diff --git a/app/javascript/router.js b/app/javascript/router.js
index 7c2db5f..312929a 100644
--- a/app/javascript/router.js
+++ b/app/javascript/router.js
@@ -42,7 +42,7 @@ export default new Router({
component: Speaker
},
{
- path: '/talks/:slug',
+ path: '/conferences/:conference_slug/talks/:talk_slug',
name: 'Talk',
component: Talk
}
diff --git a/config/routes.rb b/config/routes.rb
index 1ba047a..5a73d28 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -21,8 +21,9 @@
namespace :api, defaults: {format: :json} do
namespace :v1 do
- resources :conferences, only: [:index, :show], param: :slug
- resources :talks, only: [:show], param: :slug
+ resources :conferences, only: [:index, :show], param: :slug do
+ resources :talks, only: [:show], param: :slug
+ end
resources :speakers, only: [:index, :show], param: :slug
end
end