Skip to content

Instantly share code, notes, and snippets.

Started POST "/questions/188/answers" for 10.0.2.2 at 2017-10-31 14:31:18 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by AnswersController#create as JS
Parameters: {"utf8"=>"✓", "answer"=>{"body"=>"23gq3ga", "attachments_attributes"=>{"0"=>{"_destroy"=>"false"}}}, "commit"=>"Post your answer", "question_id"=>"188"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 40], ["LIMIT", 1]]
Question Load (0.5ms) SELECT "questions".* FROM "questions" WHERE "questions"."id" = $1 LIMIT $2 [["id", 188], ["LIMIT", 1]]
Unpermitted parameter: :_destroy
(0.3ms) BEGIN
SQL (0.9ms) INSERT INTO "answers" ("body", "created_at", "updated_at", "question_id", "user_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["body", "23gq3ga"], ["created_at", "2017-10-31 14:31:18.457710"], ["updated_at", "2017-10-31 14:31:18.457710"], ["question_id", 188], ["user_id", 40]]
(0.6ms) COMMIT
ActionView::MissingTemplate (Missing partial answers/_answer with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :slim, :coffee, :jbuilder]}. Searched in:
* "/home/ubuntu/www/qna/app/views"
* "/var/lib/gems/2.4.0/gems/devise-4.3.0/app/views"
):
app/controllers/answers_controller.rb:53:in `publish_answer'
eva@eva-CR70-2M-CX70-2OC-CX70-2OD:~$ cd vagrant/rails-dev-box
eva@eva-CR70-2M-CX70-2OC-CX70-2OD:~/vagrant/rails-dev-box$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/yakkety64' is up to date...
==> default: A newer version of the box 'ubuntu/yakkety64' is available! You currently
==> default: have version '20170217.0.0'. The latest is version '20170330.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

require 'rails_helper'
RSpec.describe AttachmentsController, type: :controller do
let(:question) { create(:question) }
let(:answer) { create(:answer, question: question, user: @user) }
let(:answer2) { create(:answer, question: question) }
describe 'DELETE #destroy' do
sign_in_user
let!(:attachment) { create(:attachment, attachable: answer) }
require 'rails_helper'
RSpec.describe AttachmentsController, type: :controller do
let!(:question) { create(:question) }
let!(:answer2) { create(:answer, question: question) }
describe 'DELETE #destroy' do
sign_in_user
let!(:answer) { create(:answer, question: question, user: @user) }
require 'rails_helper'
RSpec.describe AttachmentsController, type: :controller do
sign_in_user
describe 'DELETE #destroy' do
let!(:answer) { create(:answer, question: question, user: @user) }
let!(:question) { create(:question) }
let!(:answer2) { create(:answer, question: question) }
@Evanto
Evanto / _answer.html.slim
Created August 17, 2017 15:04
_answer и _answers мод 8 не проходят тесты delete
- if answer.best && answer.persisted?
div class="answer-#{answer.id}"
p.glyphicon.glyphicon-star class="answer-#{answer.id}" = answer.body
- elsif answer.persisted?
div class="answer-#{answer.id}"
p class="answer-#{answer.id}" = answer.body
ul
- @answer.attachments.each do |a|
li id="attachment_#{a.id}"
ubuntu@rails-dev-box:~/www/qna$ bundle install
error: cannot open .git/FETCH_HEAD: Permission denied
Retrying `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` in directory /var/lib/gems/2.4.0/bundler/gems/shoulda-matchers-ead87017a6c1 has failed.
If this error persists you could try removing the cache directory '/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8'error: cannot open .git/FETCH_HEAD: Permission denied
Retrying `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda
@Evanto
Evanto / _answer.html.slim
Last active July 11, 2017 16:45
Ajax answer update works
- if answer.persisted?
div class="answer-#{answer.id}"
= answer.body
- if current_user&.author_of? answer
p= link_to 'Edit', '', class: 'edit-answer-link', data: { answer_id: answer.id }
p= link_to "delete answer", answer_path(answer), method: :delete
p
= form_for [answer], remote: true, html: { id: "edit-answer-#{answer.id}"} do |f|
= f.label :body, "Answer"
= f.text_area :body