小编Smo*_*oth的帖子

在团队工作时正确使用Git/Github

例:

  • 我克隆了Github存储库,创建了一个新的分支并开始处理一个功能.

  • 我的同事克隆了同样精确的Github存储库,在他的本地机器上创建了自己的分支(git checkout -b mylocalbranch),并开发了自己的功能.

  • 在我做之前,我的同事完成了他的功能,并将其推向生产并回到Github.

  • 我在30分钟后完成了我的功能,并希望在不引起任何冲突的情况下推动我的工作.

什么是将我的工作推向生产并回到Github而不会引起任何冲突的最佳方法?

git github

8
推荐指数
1
解决办法
3948
查看次数

ArgumentError:使用afer_save时参数数量错误(1表示0)

ArgumentError: wrong number of arguments (1 for 0)
    from /Users/Castillo/Desktop/gainer/app/models/status.rb:13:in `update_remaining_nutrients'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:507:in `block in callback'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:504:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:504:in `callback'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:352:in `add_to_target'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:495:in `block in concat_records'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:493:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:493:in `concat_records'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:134:in `block in concat'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:149:in `block in transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:148:in `transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:134:in `concat'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_proxy.rb:116:in `<<'
    from /Users/Castillo/Desktop/gainer/app/models/user.rb:65:in `eat'
    from (irb):31
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud)

我想在用户"吃掉"用餐时在status.rb上调用update_remaining_nutrients方法.当我调用User.first.eat(Meal.first)时,我得到了ArgumentError.不知道为什么,因为我没有传递after_add方法的任何参数?

user.rb …

ruby has-many ruby-on-rails-3 rails-activerecord

7
推荐指数
1
解决办法
3239
查看次数

Rails提交按钮:如何在单击时按钮运行某个方法?

我正在学习如何构建rails应用程序,我仍然不完全理解如何使按钮做东西.如何使用表单中提供的属性运行特定方法?

forms ruby-on-rails-3

5
推荐指数
1
解决办法
1万
查看次数

运行rvm install ruby​​-2.0.0-p247时运行'make -j2'时出错

这是尝试安装Ruby 2.0时出现的错误

Error running 'make -j2',
please read /usr/local/rvm/log/ruby-2.0.0-p247/1372532765_make.log
There has been an error while running make. Halting the installation.
Run Code Online (Sandbox Code Playgroud)

我尝试按照这些步骤操作它不起作用:无法使用RVM安装Ruby 2.0.0-p0.运行'make -j8'时出错

任何有关这方面的帮助将不胜感激.我不知道该怎么办......

这是日志:

[2013-06-29 15:06:05] make
    CC = clang
    LD = ld
    LDSHARED = clang -dynamiclib
    CFLAGS = -O3 -I/opt/sm/pkg/active/include -fno-common -pipe 
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I. -I.ext/include/x86_64-darwin12.3.0 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -install_name /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/libruby.2.0.0.dylib -current_version 2.0.0 -compatibility_version 2.0.0  -fstack-protector -Wl,-u,_objc_msgSend  -fstack-protector -Wl,-u,_objc_msgSend …
Run Code Online (Sandbox Code Playgroud)

ruby rvm

5
推荐指数
1
解决办法
2454
查看次数

动画SVG在Firefox中不起作用,适用于Chrome

我不确定我需要在这个SVG中修改什么才能使它与Firefox兼容?动画在其他浏览器中运行良好,但在Firefox中它只是一个静态图像,并没有动画.

<svg width='360px' height='360px' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-balls">
    <rect x="0" y="0" width="100" height="100" fill="none" class="bk"></rect>
    <g transform="rotate(0 50 50)">
        <circle r="3" cx="30" cy="50">
            <animateTransform attributeName="transform" type="translate" begin="0s" repeatCount="indefinite" dur=".75s" values="0 0;13.819660112501051 -19.02113032590307" keyTimes="0;1" />
            <animate attributeName="fill" dur=".75s" begin="0s" repeatCount="indefinite" keyTimes="0;1" values="#DB3341;#42a3cf" />
        </circle>
    </g>
    <g transform="rotate(72 50 50)">
        <circle r="3" cx="30" cy="50">
            <animateTransform attributeName="transform" type="translate" begin="0s" repeatCount="indefinite" dur=".75s" values="0 0;13.819660112501051 -19.02113032590307" keyTimes="0;1" />
            <animate attributeName="fill" dur=".75s" begin="0s" repeatCount="indefinite" keyTimes="0;1" values="#42a3cf;#76478a" />
        </circle>
    </g>
    <g transform="rotate(144 50 50)"> …
Run Code Online (Sandbox Code Playgroud)

firefox svg svg-animate

5
推荐指数
1
解决办法
1886
查看次数

如何使用Twilio接收来自用户的短信并使用消息回复该文本?

1.)用户向指定的Twilio电话号码发送文本消息2.)应用程序接收此消息并解析它以获取可操作的数据3.)应用程序向发送者回复,并提供发送所请求信息的文本消息

我怎么用铁轨做这个?!

ruby-on-rails twilio

4
推荐指数
1
解决办法
4058
查看次数

Firebase 数据库规则,仅当文档属性等于经过身份验证的用户 ID 时才允许删除

我在我的 firebase 数据库中添加安全规则时遇到问题。如果经过身份验证的用户等于投票文档上的 uid 属性,我只想允许删除投票。除了我在匹配 /votes/{voteId} 上创建的删除规则之外,一切正常。

我试图用 resource.data.uid 来做到这一点,但模拟器抱怨,我收到错误“运行模拟时出错 - 错误:simulator.rules Null 值错误”

service cloud.firestore {
  match /databases/{database}/documents {

    match /polls/{pollId} {
      allow read;
      allow delete: if getUserData().roles.keys().hasAny(['admin']);
      allow create: if isSignedIn();
    }

    match /users/{userId} {
        allow read, write: if isOwner(userId);
    }

    match /votes/{voteId} {
        allow read;
      allow create: if isSignedIn();
      allow delete: if request.auth.uid == resource.data.uid;
    }
  }

  /// Functions ///
  function isSignedIn() {
    return request.auth != null
  }

  function isOwner(userId) {
    return request.auth.uid == userId
  }

} …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security google-cloud-firestore

4
推荐指数
1
解决办法
1188
查看次数

Angular 6 如何将 PrimeNG 全局过滤器移至 &lt;p-table&gt; 之外?

设计人员的 UI 模拟要求我将全局搜索过滤器移到 p 表之外,但我不确定如何执行此操作,或者是否可能?有没有人有做类似事情的经验?我可以严格使用 CSS 样式来做到这一点,同时保持针对不同屏幕尺寸的响应式布局吗?

<p-table #dt [value]="tags" [paginator]="true" [rows]="25" [columns]="cols" [resizableColumns]="true" [globalFilterFields]="['vendor']">
  <ng-template pTemplate="caption">
    <div style="text-align: right; overflow-x: hidden;">
      <p class="wrapper"><input type="text" class="search-vendors" pInputText size="50" placeholder="Search Vendors" (input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto"></p>
    </div>
  </ng-template>
  <ng-template pTemplate="header" let-columns>
    <tr>
      <th class="{{col.class}}" *ngFor="let col of columns" [pSortableColumn]="col.field">
        <p-sortIcon [field]="col.field" *ngIf="col.field == 'fieldThree' || col.field == 'fieldOne' || col.field == 'fieldTwo' "></p-sortIcon>
        {{col.header}}
        <fa *ngIf="col.field == 'fieldThree' || col.field == 'fieldTwo'" name="info-circle" pTooltip="{{col.tooltip}}" tooltipPosition="right" showDelay="1000" hideDelay="500"></fa>
      </th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-rowData …
Run Code Online (Sandbox Code Playgroud)

primeng angular

3
推荐指数
1
解决办法
3642
查看次数

如何在Angular 6中同步加载组件?

我有一个标头组件,该组件进行调用以获取用户令牌并存储用户的数据。然后,我有一个不同的组件(管理组件),它不是标头的子代,它依赖于用户数据来获取其他数据。我遇到的问题是管理组件在标头组件完成对用户的调用之前初始化,因此破坏了我的管理组件。换句话说,由于标题尚未设置活动公司,因此代码执行中断。有没有办法确保这些在Angular 6中同步加载,这样我就可以避免此问题?

header.component.ts

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';


@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
  user: any;
  activeCompany: any;

  constructor(private authService: AuthService) { }

  ngOnInit() {
    this.authService.getToken().then((user) => {
      this.user = user;
      this.user.Companies = JSON.parse(this.user.Companies.split('&quot;').join('"'));
      this.authService.getActiveCompany$().subscribe((company: any) => {
        if(!company) {
          let company = this.user.Companies[0]
          this.authService.setActiveCompany$(JSON.stringify(company));
        }
        this.activeCompany = company;
      });
    });
  }

  setActiveCompany(company) {
    this.authService.setActiveCompany$(company)
  }
}
Run Code Online (Sandbox Code Playgroud)

admin.component.ts

import { Component, OnInit } from …
Run Code Online (Sandbox Code Playgroud)

angular angular6

3
推荐指数
1
解决办法
549
查看次数

读取文本文件,解析它并将其存储到哈希中.怎么样?

我想打开一个包含三行的文本文件

3台电视722.49

1箱14.99的鸡蛋

两双鞋子在34.85

把它变成这个:

hash = {
      "1"=>{:item=>"televisions", :price=>722.49, :quantity=>3},    
      "2"=>{:item=>"carton of eggs", :price=>14.99, :quantity=>1},
      "3"=>{:item=>"pair of shoes", :price=>34.85, :quantity=>2}
       }
Run Code Online (Sandbox Code Playgroud)

我很不确定如何去做这件事.这是我到目前为止所拥有的:

f = File.open("order.txt", "r")
lines = f.readlines
h = {}
n = 1
while n < lines.size
lines.each do |line|
  h["#{n}"] = {:quantity => line[line =~ /^[0-9]/]}
  n+=1
end
end
Run Code Online (Sandbox Code Playgroud)

ruby file

2
推荐指数
1
解决办法
5395
查看次数

推送到 Heroku 时出现问题。在别处运行 `bundle install` 并将更新的 Gemfile.lock 添加到版本控制

我一直在尝试解决这个错误几个小时,但没有取得任何进展。我试过在不同的环境中运行 bundle install ,但没有运气。我不确定发生了什么,我觉得好像错误不再提供相关反馈。但是,我使用的是 Ruby 1.9.3,当我推送它时,会指出 Heroku 使用的是 Ruby 2.0.0。这可能与它有关吗?

Castillos-MacBook-Pro:reservester-nysum13 castillo$ git push heroku master
Identity added: /Users/castillo/.ssh/id_rsa (/Users/castillo/.ssh/id_rsa)
Counting objects: 66, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (66/66), 26.25 KiB, done.
Total 66 (delta 4), reused 38 (delta 1)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       You are trying …
Run Code Online (Sandbox Code Playgroud)

heroku ruby-on-rails-3

2
推荐指数
1
解决办法
7702
查看次数

错误TS2365:运算符“ +”不能应用于类型“ number []”和“ -1000”

即使该功能运行正常,没有问题,我在ng服务日志中仍收到以下错误。但是,当我为生产而构建时,这将成为一个问题。如何解决此错误?

uuidv4() {
    return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
      (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
    )
  }
Run Code Online (Sandbox Code Playgroud)

在我的服务中,我将其称为this.uuidv4()以生成唯一的ID。

typescript angular

0
推荐指数
1
解决办法
36
查看次数