小编zab*_*mba的帖子

rails state_machine:如何触发操作:初始状态?

这就是我所拥有的:

state_machine :state, :initial => :open do
    after_transition :on => :buy, :do => :send_buy_notification_email
    after_transition :on => :take, :do => :send_take_notification_email
    after_transition :on => :accept, :do => :send_accept_notification_email
    after_transition :on => :cancel, :do => :send_cancel_notification_email
Run Code Online (Sandbox Code Playgroud)

现在我想在初始状态打开时触发:send_trade_notification_email.

我怎么做?

干杯,

乔尔

ruby-on-rails state-machine

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

rails,wicked-pdf gem和éàö字符显示不正确

当我生成包含éèà等字符的文本的PDF时,我确实会得到有趣的字符.

我知道这必须与编码有关.

我在字符串上尝试使用force_encoding("UTF-8"),但这些字符没有成功.

乔尔

ruby-on-rails character-encoding wicked-pdf

5
推荐指数
3
解决办法
2008
查看次数

simple_form没有为json找到输入

环境Mac OS X Rails 4.0.4 Ruby 2.1.1

宝石: simple_form

创建一个带有json类型字段的模型,这里是我的迁移文件:

create_table :my_model do |t|
  t.string :name
  t.json :my_field

  t.timestamps
end
Run Code Online (Sandbox Code Playgroud)

现在当我尝试创建一个New对象(New form)时,我收到了这个错误

RuntimeError - No input found for json:
  simple_form (3.0.2) lib/simple_form/form_builder.rb:551:in `find_mapping'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:482:in `find_input'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:111:in `input'
Run Code Online (Sandbox Code Playgroud)

我猜测simple_form没有很好地处理JSON类型,我真的不知道如何解决这个问题(newbie with simple_form).

希望你能帮忙

postgresql json ruby-on-rails simple-form

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

heroku pg:psql --app my-app失败,找不到命令

环境

  • Mac OSX Maverick
  • Rails 3.2.11
  • Ruby 1.9.2p290
  • Heroku工具带

从我的终端:

$ heroku pg:psql --app my-app
---> Connecting to HEROKU_POSTGRESQL_CYAN_URL (DATABASE_URL)
sh: psql: command not found     
Run Code Online (Sandbox Code Playgroud)

postgresql heroku ruby-on-rails-3

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

无法将Node应用程序部署到Openshift

我正在尝试使用命令行工具部署一个简单的ExpressJS应用程序,我必须使用Openshift.我在下面提供了一个调试跟踪:

>npm info ok 
Preparing build for deployment
Deployment id is 5e2abc99
Activating deployment
HAProxy already running
HAProxy instance is started
Starting NodeJS cartridge
Sat Aug 15 2015 15:17:47 GMT-0400 (EDT): Starting application 'xxxxx' ...
Waiting for application port (8080) become available ...
Application 'xxxxx' failed to start (port 8080 not available)
Run Code Online (Sandbox Code Playgroud)

Git Post-Receive Result: failure
Activation status: failure
Activation failed for the following gears:
55cf8fc589f5cf9dbf00023c (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' …
Run Code Online (Sandbox Code Playgroud)

javascript node.js openshift openshift-cartridge

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

无法在 Windows Server 2012 上运行 pm2

我安装pm2在 Windows Server 2012 上

npm install pm2 -g
Run Code Online (Sandbox Code Playgroud)

我关闭了我的 PowerShell 并再次打开它。

当我尝试运行pm2它时失败并出现此错误

> pm2 list

pm2 : The term 'pm2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pm2 list
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pm2:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException …
Run Code Online (Sandbox Code Playgroud)

node.js npm pm2

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

g++:内部编译器错误:分段错误(程序 cc1plus) - 我从哪里开始?

我正在将在Ubuntu 14.04上编译的代码移植到16.04。我已经克隆了我的 git repo,安装了依赖项并尝试了通常的make命令,很快我就遇到了g++: internal compiler error: Segmentation fault (program cc1plus)......但我不确定从哪里开始诊断和解决这个问题。

我会尽可能多地分享,看看是否有人可以指导我解决问题。

Ubuntu

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial
Run Code Online (Sandbox Code Playgroud)

加++

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Run Code Online (Sandbox Code Playgroud)

Python

$ python --version
Python 2.7.12
Run Code Online (Sandbox Code Playgroud)

一些环境变量

PYTHON       /usr/bin/python2.7
ARCH         x86_64
OS           Linux
VERSION      4.4.071generic
PLATFORM     linux2
HOSTNAME     deploy
USER         myUser
WUSS_BUILD   NO
CCVER        gcc
PYLIBDIR     build.x86_64-linux2
LIBDIR       build.x86_64-linux2
BINDIR       build.x86_64-linux2 …
Run Code Online (Sandbox Code Playgroud)

c++ makefile g++ ubuntu-14.04 ubuntu-16.04

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

致命错误:numpy / arrayobject.h:没有此类文件或目录

我的共享能力受到限制,因为这是我从Ubuntu 14.04移植到16.04的大量代码的一部分。

这应该是微不足道的,但是我却为此而苦苦挣扎。找不到numpy/arrayobject.h我在源文件中引用的#include <numpy/arrayobject.h>

我将尽力分享尽可能多的东西,看看是否有人可以指导我解决问题。

的Ubuntu

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial
Run Code Online (Sandbox Code Playgroud)

使

$ make --version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Run Code Online (Sandbox Code Playgroud)

g ++

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Run Code Online (Sandbox Code Playgroud)

升级到

# g++ --version
g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even …
Run Code Online (Sandbox Code Playgroud)

c++ python numpy g++

4
推荐指数
2
解决办法
6544
查看次数

我可以将我的heroku git repo导入bitbuket吗?如何?

我的笔记本电脑坏了,我需要从另一台电脑编码.

我正在使用Heroku,我想从Heroku到另一台机器获取最新版本的代码.

我知道非常建议使用GitHub或BitBucket获取正确的远程存储库.

我决定尝试BitBucket.

在创建我的帐户时,它会询问我的git repo的旧网址.由于我的机器已经死了,我希望填写heroku URL,但这不起作用.

任何想法如何进行?

我的想法是,我可以从任何一台机器拉动并推动我的更改(当我的笔记本电脑来自维修时).

git heroku bitbucket ruby-on-rails-3

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

rake db:rollback恢复错误的迁移

我有一个问题要恢复上次迁移.

自从我安装了'letrate'宝石进行评级后,任何rake db:rollback恢复精确地都会让宝石迁移,而不是最后的迁移.

我怀疑这是由于宝石本身.

任何想法如何解决这个问题,所以我可以享受非常方便的回滚?

同样的问题:

rake db:migrate:redo
Run Code Online (Sandbox Code Playgroud)

结果:

==  CreateRates: reverting ====================================================
-- drop_table(:rates)
   -> 0.0224s
==  CreateRates: reverted (0.0225s) ===========================================

==  CreateRates: migrating ====================================================
-- create_table(:rates)
NOTICE:  CREATE TABLE will create implicit sequence "rates_id_seq" for serial column "rates.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "rates_pkey" for table "rates"
   -> 0.1787s
-- add_index(:rates, :rater_id)
   -> 0.0032s
-- add_index(:rates, [:rateable_id, :rateable_type])
   -> 0.0024s
==  CreateRates: migrated (0.1850s) ===========================================
Run Code Online (Sandbox Code Playgroud)

rake db:migrate:status

...
   up …
Run Code Online (Sandbox Code Playgroud)

rake rails-migrations ruby-on-rails-3.2

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