小编Ani*_*dha的帖子

发布在Github中推送新代码的问题

我在Github上创建了一个新的存储库,它现在只有Readme.md文件.

我有一个新创建的RoR项目,我想将其推送到此存储库.以下是我在终端中执行的命令以及我得到的错误.

git remote add origin https://github.com/aniruddhabarapatre/learn-rails.git
Run Code Online (Sandbox Code Playgroud)

之后我输入了用户名和密码

git push -u origin master
Run Code Online (Sandbox Code Playgroud)

错误---

To https://github.com/aniruddhabarapatre/learn-rails.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/aniruddhabarapatre/learn-rails.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note …
Run Code Online (Sandbox Code Playgroud)

git github git-push

142
推荐指数
7
解决办法
18万
查看次数

安装gem失败,权限错误

我昨天将Mac OS更新为10.9 Mavericks.我目前的Ruby版本显示为

ruby 2.0.0p247(2013-06-27修订版41674)[universal.x86_64-darwin13]

我在我的机器上安装了Rails,当我尝试安装gem时,我得到以下消息:

Fetching: eventmachine-1.0.3.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

我在我的主目录中尝试所有这些.有什么建议?

ruby macos rubygems

10
推荐指数
3
解决办法
4万
查看次数

在 SQLAlchemy 中创建动态类

我们有 1 个包含大量数据的表,DBA 根据特定参数对其进行分区。这意味着我最终得到了Employee_TX, Employee_NY一些表名。早些时候,这models.py很简单——

class Employee(Base):
    __tablename__ = 'Employee'
    name = Column...
    state = Column...
Run Code Online (Sandbox Code Playgroud)

现在,我不想为新分区的表创建 50 个新类,因为无论如何我的列是相同的。

是否有一种模式可以让我创建一个类,然后动态地在查询中使用它?session.query(<Tablename>).filter().all()

也许某种工厂模式或其他东西就是我正在寻找的。

到目前为止,我已经尝试运行一个循环

for state in ['CA', 'TX', 'NY']:
    class Employee(Base):
        __qualname__ = __tablename__ = 'Employee_{}'.format(state)
        name = Column...
        state = Column...
Run Code Online (Sandbox Code Playgroud)

但这不起作用,我收到警告 -SAWarning: This declarative base already contains a class with the same class name and module name as app_models.employee, and will be replaced in the string-lookup table.

当我这样做时它也找不到生成的类from app_models import Employee_TX

这是一个 …

python python-2.7 flask-sqlalchemy

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

zsh:找不到命令:mysql

尝试将MySQL用于Rails应用程序,并从dev.mysql.com下载了它。

成功安装软件包并查看从“首选项窗格”启动和停止服务器的选项后,如果我继续在终端中执行以下命令

mysql --version
Run Code Online (Sandbox Code Playgroud)

我最终出现以下错误:

zsh: command not found: mysql
Run Code Online (Sandbox Code Playgroud)

我一直在寻找这个错误,明白,这事做与我的$PATH变量,如果显示的值由echo $PATH我得到下面的输出-

/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1@global/bin:/Users/aniruddhabarapatre1/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/Users/aniruddhabarapatre1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/opt/ImageMagick/bin:/usr/local/MacGPG2/bin:/Users/aniruddhabarapatre1/.rvm/bin
Run Code Online (Sandbox Code Playgroud)

如何解决此错误以启动并运行Mysql。

mysql macos zsh ruby-on-rails

5
推荐指数
6
解决办法
9591
查看次数

要点没有得到颜色编码

我上传了一些代码gist.github,但看不到它们的颜色格式化.我已经改变了语言并尝试了其他几个我编码的语言,但所有这些都是相同的.

例如:虚拟Ruby代码

如何使其格式化很好?

ruby gist github

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

按字符串格式包含日期的键对哈希进行排序

我有一个包含日期字符串格式的哈希 -

{Oct 2014: "some value", Aug 2012: "some value", July 2011: "new value"}
Run Code Online (Sandbox Code Playgroud)

我想根据它们对它们进行排序.我尝试调用sort_by或对键进行排序,但由于它们以字符串格式存储,因此按字母顺序对它们进行排序.

hash_name.keys.sort
Run Code Online (Sandbox Code Playgroud)

这给了我2012年8月,2011年7月,2014年10月的顺序.虽然我想按照年份和月份的顺序对它们进行排序,如2011年7月,2012年8月,2014年10月

ruby sorting hash

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

内联块在firefox中添加额外空间

我有一个网页,我已经将我的div与内联块属性叠加在一起.但是,它只在Firefox中的两个div之间增加了额外的间距.该设计在Safari和Chrome中保持一致.

这是小提琴的样本.

#main {
    display: block;
}
#sub11, #sub12, #sub21, #sub22,  #sub31, #sub32 {
    display: inline-block;
    background:red;
    padding:0;
    //margin-right:-4px;
    margin-top:3px;
    margin-bottom:3px;
}
Run Code Online (Sandbox Code Playgroud)

Firefox 在行GHITRY行之间增加了额外的空间,而ABC和GHI与TRY之后的其他行一致.

css firefox

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

安装pg gem时出错

为了将我的rails应用程序部署到heroku,我通过添加更改了我的Gemfile

gem 'pg'
Run Code Online (Sandbox Code Playgroud)

我曾经做过

bundle install
Run Code Online (Sandbox Code Playgroud)

我收到以下错误 -

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1) 
Using i18n (0.6.9) 
Using minitest (4.7.5) 
Using multi_json (1.8.2) 
Using atomic (1.1.14) 
Using thread_safe (0.1.3) 
Using tzinfo (0.3.38) 
Using activesupport (4.0.0) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0) 
Using mime-types (1.25.1) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.0) 
Using activemodel (4.0.0) 
Using activerecord-deprecated_finders (1.0.3) …
Run Code Online (Sandbox Code Playgroud)

macos gem heroku pg ruby-on-rails-4

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