小编oll*_*leh的帖子

Laravel Production问题 - 使用Laravel 4.1.x更新作曲家

到目前为止,我在部署laravel项目时没有遇到任何问题.我已经为这个项目部署了差不多一年的时间.但是出现了一些新的bug.

首先.我无法运行composer update,因为它说出了这个错误.

composer update
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
Loading composer repositories with package information
Updating dependencies (including require-dev)



  [RuntimeException]
  Could not load package classpreloader/classpreloader in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ^1.2.2: Invalid
   version string "^1.2.2"






  [UnexpectedValueException]
  Could not parse version constraint ^1.2.2: Invalid version string "^1.2.2"



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] …
Run Code Online (Sandbox Code Playgroud)

php laravel composer-php

16
推荐指数
2
解决办法
3万
查看次数

Laravel - 播种大型SQL文件

当我在生产中运行我的DB种子脚本时,会发生内存耗尽.

下面是我的种子脚本.

class MembershipTableSeeder extends Seeder 
{
    public function run()
    {
        DB::table('members')->delete();

        foreach (range(1, 99) as $days){
            Members::create(array('membership_code' => 'test'.$days));
        }

        DB::unprepared(file_get_contents(app_path()."/database/seeds/members.sql"));
    }
}
Run Code Online (Sandbox Code Playgroud)

所以我所做的是在我的种子脚本上添加一个无限制.

ini_set('memory_limit', '-1');
Run Code Online (Sandbox Code Playgroud)

现在的问题是,当我运行脚本时,它会将输出记录到终端中,SQL脚本的内容(非常非常大).

有没有一种在我的数据库种子中运行SQL转储的好方法,它不会消耗太多内存?我现在做的是手动运行:

mysql -uuser -p db < script.sql
Run Code Online (Sandbox Code Playgroud)

sql laravel laravel-4 laravel-eloquent

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

Python Sql Alchemy - 如何从数据库查询中对类对象结果进行json化

基本上,我只想json编码我的SQL查询的结果.

x = db.session.query(User).filter_by(username = request.form['username'], password = request.form['password']).first()
  print vars(x)
return jsonify(x)

raise TypeError(repr(o) + " is not JSON serializable")

TypeError: < User WashingtonGeorge> is not JSON serializable
Run Code Online (Sandbox Code Playgroud)

这是打印变量的结果(x)

{'_updated': None, 'username': u'WashingtonGeorge', 'password': u'Washington', '_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7fd12a50c8d0>, 'firstname': u'George', 'lastname': u'Washington', '_created': None, 'fullname': u'George Washington', '_id': 1, 'email': u'WashingtonGeorge@yahoo.com'}
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy flask eve

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

当我使用TMUX时,我无法在Sublime中打开文件夹

操作系统:Yosemite iterm2,zsh

当我运行"subl"时.在我的终端上,我可以打开文件夹,但如果我运行tmux和"subl project-folder",则文件夹不会打开.

?  ~  whereis subl
/usr/bin/subl

?  ~  which subl
/usr/local/bin/subl

?  ~  subl -v
Sublime Text Build 3083

?  ~  cat .bashrc
export PATH=~/bin:/Users/olleh/bin:/Users/olleh/bin:/Users/olleh/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

?  ~  cat .bash_profile
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH=/usr/local/node/bin:$PATH
export MANPATH=/usr/local/node/share/man:$MANPATH

?  ~  ls -l /usr/local/bin/subl
lrwxr-xr-x  1 root  staff  62 Jul 13 09:51 /usr/local/bin/subl -> /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl
Run Code Online (Sandbox Code Playgroud)

tmux.conf

# Use vim keybindings in copy mode
set -g …
Run Code Online (Sandbox Code Playgroud)

zsh sublimetext3 iterm2 osx-yosemite

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

安装 unf_ext 时捆绑包安装失败。“安装 unf_ext 时无法分配内存错误”

我的远程服务器上发生了这个错误。

尽管这在我的本地环境中无法复制。

安装带有本机扩展的 unf_ext 0.0.7.2

Gem::Ext::BuildError: 错误: 无法构建 gem 本机扩展。

/home/ubuntu/.rbenv/versions/2.1.2/bin/ruby extconf.rb
Run Code Online (Sandbox Code Playgroud)

无法分配内存 - /home/ubuntu/.rbenv/versions/2.1.2/bin/ruby extconf.rb 2>&1

Gem files will remain installed in /home/ubuntu/switch-web/shared/bundle/ruby/2.1.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /home/ubuntu/switch-web/shared/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/unf_ext-0.0.7.2/gem_make.out
An error occurred while installing unf_ext (0.0.7.2), and Bundler cannot
continue.
Make sure that `gem install unf_ext -v '0.0.7.2'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

我检查了我的服务器的 RAM 空间,它仍然相当不错(2GB 免费)。

ruby ruby-on-rails bundler

6
推荐指数
2
解决办法
1845
查看次数

Python SQL Alchemy如何通过排除选定的列进行查询

我基本上只需要知道如何通过排除选定的列进行查询.这可能吗?

示例:我的桌子有id,姓名,年龄,地址,位置,出生年龄,性别......等.

我想要排除查询中的某些列(例如,排除年龄),而不是引用要检索的列.

示例代码:

db.session.query(User.username).filter_by(username = request.form['username'], password = request.form['password']).first()
Run Code Online (Sandbox Code Playgroud)

我想做的最后一件事是列出query()方法的所有属性,因为这将是非常长的,特别是当你有很多属性时,因此我只想排除一些列.

python sqlalchemy flask-sqlalchemy

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

无法在MAMP上安装mysql2 Gem

运行软件包安装后,出现此错误。我试过编辑/ etc / paths文件,但仍然没有用。

Gem :: Ext :: BuildError:错误:无法构建gem本机扩展。

/Users/adam/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150224-4249-ltvvu1.rb extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due …
Run Code Online (Sandbox Code Playgroud)

ruby mamp ruby-on-rails mysql2

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

使用单词数组创建活动管理员输入下拉列表

如何在Active admin中创建自定义输入字段?

这是输入字段性别,包含["男性","女性"]

ruby-on-rails activeadmin

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