我正在使用Rails和Backbone,我已经学到了很多,但我遇到了一个问题,我无法解决这个问题.
我有两个模型,一个用户和一个电影模型.
ActiveRecord::Schema.define(version: 20141016152516) do
create_table "movies", force: true do |t|
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
create_table "users", force: true do |t|
t.string "name"
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_digest"
t.string "remember_digest"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
end
Run Code Online (Sandbox Code Playgroud)
用户模型具有多部电影,电影模型为belongs_to用户.
我一直在使用Backbone集合将电影添加到用户的视图中,就像这样,
class Movieseat.Collections.Movieseats extends Backbone.Collection
url: '/api/movies'
defaults:
title: ""
Run Code Online (Sandbox Code Playgroud)
通过我的索引视图
class Movieseat.Views.MovieseatsIndex extends Backbone.View
template: JST['movieseats/index']
initialize: ->
@collection.on('update', @render, this)
@collection.on('add', @appendEntry, this)
render: ->
$(@el).html(@template())
@collection.each(@appendEntry)
this
events: -> …Run Code Online (Sandbox Code Playgroud) 我有一个具有多种方法的 Inventory 类。2 方法返回他们拥有的所有狮子和狼。一种方法是将狮子和狼的数组合并为一个数组。最后,我有一个方法,我想用它根据输入过滤掉某些对象。
class Inventory {
getAllLions(): ILion[] {
const lions = [
{ id: 1, name: 'Joffrey', gender: Gender.male, vertrabrates: true, warmBlood: true, hair: 'Golden', runningSpeed: 30, makeSound() { } },
{ id: 2, name: 'Tommen', gender: Gender.male, vertrabrates: true, warmBlood: true, hair: 'Golden', runningSpeed: 30, makeSound() { } },
{ id: 3, name: 'Marcella', gender: Gender.female, vertrabrates: true, warmBlood: true, hair: 'Golden', runningSpeed: 30, makeSound() { } },
];
return lions;
}
getAllWolves(): IWolf[] {
const wolves: …Run Code Online (Sandbox Code Playgroud) 我正在按照本教程使用 Spring 创建一个 CRUD 应用程序。我想创建一个存储库,并希望它扩展 Spring CrudRepository:
package com.movieseat.repositories;
import java.io.Serializable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.movieseat.models.Movie;
public interface MovieRepository extends CrudRepository<Movie, Serializable> {}
Run Code Online (Sandbox Code Playgroud)
Visual Studio Code 说:
导入 org.springframework.data 无法解析
我已经删除了 .m2 文件夹中的存储库文件夹并重新安装,但仍然没有成功。
我想我的 pom.xml 文件中缺少一个依赖项,但我找不到它是哪一个。
//编辑。共享后端文件夹中的 pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>backend</artifactId>
<name>backend</name>
<description>The backend project</description>
<parent>
<groupId>com.jdriven.ng2boot</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.movieseat.Application</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的网站保存并输出一些数据但是当我查看我显示的movies.json文件时,
[null,null,null,null,null,null,null,null]
Run Code Online (Sandbox Code Playgroud)
对于我的数据库中的每个ID,这都是null.
这是来自Rails服务器的日志,
Started GET "/movies.json" for 127.0.0.1 at 2015-08-25 07:52:48 +0200
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by MoviesController#index as JSON
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
Movie Load (0.1ms) SELECT "movies".* FROM "movies"
Completed 200 OK in 116ms (Views: 10.1ms | ActiveRecord: 4.5ms)
Run Code Online (Sandbox Code Playgroud)
在我的application_controller.rb中我有
respond_to :html, :json
Run Code Online (Sandbox Code Playgroud)
我的movies_controller.rb
class MoviesController < ApplicationController
def index
respond_with Movie.all
end
def create
respond_with Movie.create(movie_params)
end …Run Code Online (Sandbox Code Playgroud) 我有一个Icon元素,我想根据其他东西切换类,
%i.fa.fa-bell{"ng-class" => "newActivities"}
Run Code Online (Sandbox Code Playgroud)
我的控制器中有一个if/else语句,
var activities = $scope.activities
var init = function(){
var hasValue = activities.some(function(obj) { return obj.viewed == "uncheck" });
console.log (hasValue)
if (hasValue == true){
checked = true ;
$scope.newActivities = 'newActivities';
}
}
$scope.viewActivities = function (){
angular.forEach(activities, function (activitie) {
viewActivities.update({
viewed: `check`,
id: activitie.id
}).then(init);
});
$scope.newActivities = '';
}
Run Code Online (Sandbox Code Playgroud)
现在发生的是当if值为true时,将其$scope.newActivities添加newActities到ng-class元素.但是,当语句不正确时,我无法弄清楚如何删除类.
在我的 Azure DevOps 构建任务中,我运行了 Cypress 测试。如果测试失败,则取消构建。但是我想在赛普拉斯发布测试结果后运行另一个任务。
我已经在我的 pipeline.yml 文件中尝试了这个任务:
- task: PowerShell@2
inputs:
targetType: "inline"
script: "yarn test:cypress"
errorActionPreference: "continue"
displayName: "start server and run cypress"
Run Code Online (Sandbox Code Playgroud)
但这似乎没有任何影响。
我试过添加-ErrorAction 'Continue'到脚本”
"start": "npm-run-all -s build:shared-web run:shell",
"cy:run": "cypress run -ErrorAction 'Continue'",
"test:cypress": "start-server-and-test start http://localhost:3000 cy:run"
Run Code Online (Sandbox Code Playgroud)
但这失败了:
错误:未知选项:-E
看起来赛普拉斯将ErrorAction视为赛普拉斯参数。
那么,如果任务失败,继续构建的正确方法是什么?
angularjs ×1
azure-devops ×1
backbone.js ×1
javascript ×1
json ×1
ruby ×1
spring ×1
typescript ×1