Ubuntu 14.04.
所以一切都运行良好,我的终端打开了两个标签 - 一个标签在我的sebcoles项目上运行webbrick,另一个标签我用来克隆我的english_teacher repo.这一切都下载得很好,我改成了目录.
我会在这里粘贴所有内容 - 这一切都很清楚:
andrew:projects$ cd pinteresting
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /home/andrew/projects/pinteresting/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
ruby-2.1.5 is not installed.
To install do: 'rvm install ruby-2.1.5'
andrew:pinteresting$ rvm install ruby-2.1.5
Warning, new version of rvm available '1.26.11', you are using older version '1.26.10'.
You …Run Code Online (Sandbox Code Playgroud) 我为我的 koa 应用程序制作了一个自定义错误处理程序,它运行良好(除了一个症结点) - 使用 ctx.throw()意味着任何堆栈跟踪都被发送到服务器日志,并且任何自定义错误消息都会在响应中发送。
的一个问题是,Content-Type标题是text/plain,但我真的需要它application/json。
app.js:
import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import logger from 'koa-morgan';
import authentication from './middleware/authentication';
import config from './config';
import errorHandler from './middleware/error-handler';
import notificationsRoutes from './routes/notifications';
const app = new Koa();
app.use(errorHandler);
app.use(bodyParser());
app.use(logger(config.logLevel));
app.use(authentication);
app.use(notificationsRoutes.routes());
export default app;
Run Code Online (Sandbox Code Playgroud)
error-handler.js:
export default async (ctx, next) => {
return next().catch(({ statusCode, message }) => {
ctx.throw(statusCode, JSON.stringify({ message }));
}); …Run Code Online (Sandbox Code Playgroud) GitHub回购:https://github.com/Yorkshireman/mywordlist
我用谷歌搜索了这个.我确定有一种方法,可能需要在html选项哈希中使用一些代码,但我无法解决它.有任何想法吗?
当访问具有一个或多个类别的Word的_edit_word_form.html.erb部分时,"类别"复选框全部未选中,要求用户再次选择它们,即使他们不想更改类别.
:title和:description的文本字段已预先填充(谢天谢地).
_edit_word_form.html.erb:
<%= form_for(@word) do %>
<%= fields_for :word, @word do |word_form| %>
<div class="field form-group">
<%= word_form.label(:title, "Word:") %><br>
<%= word_form.text_field(:title, id: "new_word", required: true, autofocus: true, class: "form-control") %>
</div>
<div class="field form-group">
<%= word_form.label(:description, "Definition:") %><br>
<%= word_form.text_area(:description, class: "form-control") %>
</div>
<% end %>
<%= fields_for :category, @category do |category_form| %>
<% if current_user.word_list.categories.count > 0 %>
<div class="field form-group">
<%= category_form.label(:title, "Choose from existing Categories:") %><br>
<%= category_form.collection_check_boxes(:category_ids, current_user.word_list.categories.all, …Run Code Online (Sandbox Code Playgroud) <div id='messagesDiv'></div>
我想测试这个div元素是空的.
var messagesDiv = element(by.id('messagesDiv'));
expect(messagesDiv).to...
Run Code Online (Sandbox Code Playgroud)
我怎么做到这一点?
我在我的控制器规范中使用了这个:
controller.class.skip_before_action
Run Code Online (Sandbox Code Playgroud)
具体来说,在这种情况下:
controller.class.skip_before_action:require_authorisation_to_view_materials
MaterialsController:
class MaterialsController < ApplicationController
before_action :set_material, only: [:show, :edit, :update, :destroy]
before_action :require_authorisation_to_view_materials, only: [:index, :show]
def require_authorisation_to_view_materials # For Materials Page
unless user_signed_in? && current_user.can_view_materials?
redirect_to root_path, alert: "You are not authorised to view the Materials page."
end
end
# GET /materials
# GET /materials.json
def index
@materials = Material.all
end
# GET /materials/1
# GET /materials/1.json
def show
end
# GET /materials/new
def new
@material = Material.new
end
# GET /materials/1/edit
def edit …Run Code Online (Sandbox Code Playgroud) 我知道这已被问了很多次,但我已经检查了其他几个问题和答案,我仍然没有接近解决我的问题.
index.html的:
<!doctype html>
<html lang="en" ng-app="GitUserSearch">
<head>
<meta charset="utf-8">
<title>Github user search</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="bootstrap_css_overrides/bootstrap_overrides.css">
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="js/secrets.js"></script>
<script src="js/app.js"></script>
<script src="js/gitUserSearchController.js"></script>
</head>
<body ng-controller="GitUserSearchController as searchCtrl">
<div class="container">
<br>
<form class="form-horizontal">
<input type="text" ng-model="searchCtrl.searchTerm" ng-change="searchCtrl.doSearch()" ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0} }">
<button class="btn btn-primary" ng-click="searchCtrl.doSearch()">Search</button>
</form>
<br>
<ul class="list-group">
<li ng-repeat="user in searchCtrl.searchResult.items">
<img ng-src="{{user.avatar_url}}&s=50">
<a ng-href="{{user.html_url}}">{{user.login}}</a>
</li>
</ul>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JS/secrets.js:
githubToken = "longGithubTokenThatICannotShareHerePublicly"; …Run Code Online (Sandbox Code Playgroud) javascript ×3
ruby ×2
angularjs ×1
checkbox ×1
forms ×1
koa ×1
protractor ×1
rspec ×1
rspec-rails ×1
rvm ×1