Skip to content

Commit

Permalink
Fixed issue #47
Browse files Browse the repository at this point in the history
  • Loading branch information
delucas committed Oct 2, 2019
1 parent a66b290 commit 57ae3db
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/Conference.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<section class="talks-grid">
<article class="talk" v-for="talk in conference.talks" :key="talk.id">
<div class="video">
<router-link :to="{ name: 'Talk', params: { slug: talk.slug } }">
<router-link :to="{ name: 'Talk', params: { conference_slug: conference.slug, talk_slug: talk.slug } }">
<img :alt="talk.title" :src="talk.video_thumbnail" :title="talk.title">
</router-link>
</div>
Expand Down Expand Up @@ -78,7 +78,7 @@
>{{ speaker.name }}</router-link>
</p>
<h1 class="title">
<router-link :to="{ name: 'Talk', params: { slug: talk.slug } }">{{ talk.title }}</router-link>
<router-link :to="{ name: 'Talk', params: { conference_slug: conference.slug, talk_slug: talk.slug } }">{{ talk.title }}</router-link>
</h1>
</div>
</header>
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/Speaker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<section class="talks-grid">
<article class="talk" v-for="talk in speaker.talks" :key="talk.slug">
<div class="video">
<router-link :to="{ name: 'Talk', params: { slug: talk.slug } }">
<router-link :to="{ name: 'Talk', params: { conference_slug: talk.conference.slug, talk_slug: talk.slug } }">
<img :alt="talk.title" :src="talk.video_thumbnail" :title="talk.title">
</router-link>
</div>
Expand All @@ -41,7 +41,7 @@
>{{ talk.conference.title }}</router-link>
</p>
<h1 class="title">
<router-link :to="{ name: 'Talk', params: { slug: talk.slug } }">{{ talk.title }}</router-link>
<router-link :to="{ name: 'Talk', params: { conference_slug: talk.conference.slug, talk_slug: talk.slug } }">{{ talk.title }}</router-link>
</h1>
</div>
</header>
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/components/Talk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default new Router({
component: Speaker
},
{
path: '/talks/:slug',
path: '/conferences/:conference_slug/talks/:talk_slug',
name: 'Talk',
component: Talk
}
Expand Down
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57ae3db

Please sign in to comment.