小编Joh*_*ana的帖子

图标没有在heroku中显示,但它们是本地的

application.rb中

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Gcp
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails heroku

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

如何自动将当前user_id添加到另一个表?

我一直在玩这些模型.

我正在使用设计

我的架构:

  create_table "complaints", force: :cascade do |t|
    t.string   "title"
    t.text     "complaint_info"
    t.datetime "created_at",     null: false
    t.datetime "updated_at",     null: false
    t.integer  "user_id"
  end

  add_index "complaints", ["user_id"], name: "index_complaints_on_user_id", using: :btree

  create_table "users", force: :cascade do |t|
    ...
  end
Run Code Online (Sandbox Code Playgroud)

投诉模式:

class Complaint < ActiveRecord::Base
  belongs_to :user

  validates :title, presence: true
end
Run Code Online (Sandbox Code Playgroud)

用户型号:

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  has_many :complaints
end …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails devise

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

npm install express-generator不安装快递

我正在关注需要我快速安装的MEAN堆栈教程:

我运行这个:

npm install -g express-generator

这是我的结果:

username@username-Inspiron-3521:~$ npm install -g express-generator
/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express
express-generator@4.13.1 /home/username/npm/lib/node_modules/express-generator
??? sorted-object@1.0.0
??? mkdirp@0.5.1 (minimist@0.0.8)
??? commander@2.7.1 (graceful-readlink@1.0.1)
Run Code Online (Sandbox Code Playgroud)

但是当我这样做的时候

express --ejs flapper-news

The program 'express' is currently not installed. You can install it by typing:
sudo apt-get install node-express
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

谢谢你的时间.

编辑

当我做 npm install

username@username-Inspiron-3521:~/Documents/mean/flapper_news$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Linux 3.16.0-51-generic
npm ERR! argv "/home/username/local/bin/node" "/home/username/local/bin/npm" "install"
npm ERR! node v4.2.1
npm ERR! npm  v2.14.7
npm …
Run Code Online (Sandbox Code Playgroud)

node.js express mean-stack

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

预期 0 个参数,但得到 1 个。使用 typescript 并从 react-apollo 撰写

我正在使用打字稿和 react-apollo

我的代码如下: 在此处输入图片说明

如果我删除最后(Index)一个错误将消失,但我不知道如何导出容器/组件。

基本上,代码有效,但打字稿对此并不满意。

typescript apollo reactjs react-apollo

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

逐步在rubyonrails上使用贝宝创建一个简单的结帐

我目前正在尝试以固定的价格制作“立即购买”按钮。

用户付款后,我想将它们重定向到根URL并向他们发送带有附件PDF文件的电子邮件。

我一直在研究如何使用Paypal创建简单的结帐,但是没有成功,我发现使用了多年的教程已经过时了,其中一些代码已被弃用。

我已经尝试过使用BRAINTREE,它在测试/沙盒中效果很好,但是由于我目前居住在波多黎各,所以我无法创建生产帐户(这限制了我在支付网关上的选择)。

到目前为止我做了什么

跟随教程

我创建了一个支架的products使用nameunit_price

在我的product模型中:

# This defines the paypal url for a given product sale
def paypal_url(return_url)
values = {
:business => YOUR_MERCHANT_EMAIL,
:cmd => '_cart',
:upload => 1,
:return => return_url,
:invoice => UNIQUE_INTEGER
}

values.merge!({
"amount_1" => unit_price,
"item_name_1" => name,
"item_number_1" => id,
"quantity_1" => '1'
})

# This is a paypal sandbox url and should be changed for production.
# Better define this url in …
Run Code Online (Sandbox Code Playgroud)

paypal ruby-on-rails paypal-sandbox

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

即使关闭终端后,如何为reactjs运行npm start?

我一直在关注 Facebook 的 ReactJS 教程

我安装了npm install -g create-react-app https://www.npmjs.com/package/react-scripts并用它创建了应用程序

但现在我很困惑如何将我的应用程序部署到例如数字海洋?我知道我可以用来pm2运行节点服务器,但我不知道它是如何npm start工作的,因为它只是在 package.json 中运行它

{
  "name": "hello-world",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "0.7.0"
  },
  "dependencies": {
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "express": "^4.14.0",
    "mongoose": "^4.6.8",
    "react": "^15.3.2",
    "react-dom": "^15.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
Run Code Online (Sandbox Code Playgroud)

"start": "react-scripts start"它实际上从那里开始是什么?

另外,它说要构建您的应用程序以供部署使用npm run build,只会给我一个名为的文件夹build,但我找不到任何可以运行的内容node

node.js npm reactjs

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

Angular 4材质工具栏颜色未更改

我正在尝试为angular 4项目设置Angular Material。

我遵循了“入门指南”,除几件事外,几乎都有其他所有内容

  1. 添加时,工具栏组件不会更改颜色 color="primary"
  2. 工具栏的字体系列似乎不正确,实际上,我认为它试图获取的CSS是不正确的。
  3. 不需要自定义材质组件的字体家族很奇怪

我在这里使用angular-cli 1.4.9 设置了一个简单的存储库

javascript angular-cli angular-material2 angular

0
推荐指数
3
解决办法
8943
查看次数

使用vim作为javascript开发的ide?

我正在尝试为某种类型的IDE尝试VIM,我已经安装了vimrc,因为它看起来很不错.

我缺少的是linting配置语法错误,什么不是,某种intellisense(我认为vim-javascript的确如此).

根据我的阅读,vim-pathogen是安装vim特定插件的方法.

我已经按照vim-javascript中的文档介绍了如何使用病原体进行安装.我注意到安装后我看到文字颜色不同但我仍然没有得到任何类型的自动完成.

我尝试将配置添加到我的.vimrc文件中,但我不认为我做得对.

这是它的样子:

set runtimepath+=~/.vim_runtime

 execute pathogen#infect()
 source ~/.vim_runtime/vimrcs/basic.vim
 source ~/.vim_runtime/vimrcs/filetypes.vim
 source ~/.vim_runtime/vimrcs/plugins_config.vim
 source ~/.vim_runtime/vimrcs/extended.vim
 let g:javascript_plugin_jsdoc = 1
 let g:javascript_plugin_ngdoc = 1
 let g:javascript_plugin_flow = 1
 set foldmethod=syntax

 try
 source ~/.vim_runtime/my_configs.vim
 catch
 endtry
Run Code Online (Sandbox Code Playgroud)

javascript vim vim-plugin vim-syntax-highlighting

-1
推荐指数
1
解决办法
1453
查看次数