Skip to content

Commit

Permalink
Merge pull request #7 from enpitut2018/kousuke
Browse files Browse the repository at this point in the history
Kousuke
  • Loading branch information
HinakoIzumi authored Oct 24, 2018
2 parents c605e79 + 71e8188 commit 0245c50
Show file tree
Hide file tree
Showing 9 changed files with 1,911 additions and 13 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \

# Cannot find module node-sass対策
RUN yarn add node-sass
RUN yarn add axios

RUN mkdir /hakohugu_winter

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/api/questions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Api::QuestionsController < ApplicationController
def show
render 'show', formats: 'json', handlers: 'jbuilder'
end
end
3 changes: 2 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8
class HomeController < ApplicationController
def index
@question="研究の動機は?";
@question="何が課題か?";
end
end
16 changes: 15 additions & 1 deletion app/javascript/packs/hello_vue.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import Vue from 'vue/dist/vue.esm'
import axios from 'axios';

document.addEventListener('DOMContentLoaded', () => {

const app = new Vue({
el: '#app',
data: {
answer: "",
note: ""
note: "",
question: []
},
methods: {

addAnswerToNote: function (){
this.note += this.question[0]
this.note += "\n"
this.note += this.answer
this.note += "\n"
this.answer = ""
},
hoge: function(id){
axios.get(`api/questions/${id}`)
.then(res => {
this.question.push(res.data.title);
this.addAnswerToNote();
});

}
}
})
Expand Down
2 changes: 2 additions & 0 deletions app/views/api/questions/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# coding: utf-8
json.title "何が課題か?"
6 changes: 3 additions & 3 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file-text"></span>
年末販売{{answer}}-----
{{note}}
年末販売

</a>
<hr>
</li>
Expand All @@ -122,7 +122,7 @@
<textarea v-model="answer" class="form-control" id="exampleFormControlTextarea1" rows="12"></textarea>
</div>
<div class="form-group">
<button @click="addAnswerToNote" class="btn btn-primary btn-lg btn-block">回答</button>
<button @click='hoge(1)' class="btn btn-primary btn-lg btn-block">回答</button>

</div>
<div class="card">
Expand Down
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
root to: 'home#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'home#index'
namespace :api do
resources :questions, only: %i(show)
end
end
Loading

0 comments on commit 0245c50

Please sign in to comment.