没用过,猜测
如果是 RVM /home/your_name/.rvm/wrappers/default/ruby;
和 2 不同,以public/uploads
为例
set :linked_dirs, fetch(:linked_dirs) + %w{public/system public/uploads}
def g_salt(len)
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
salt = ""
1.upto(len) {|i| salt << chars[rand(chars.size-1)]}
salt
end
g_salt 4
我也折腾过一阵。最大的感触是 ejabberd 没有 erlang 大牛就别去折腾了。openfire 倒是可以,但是大家都说集群支持差,没实践过。如果只是作为一个模块,第三方服务方便。
那些钩子方法全部在事务里面,出问题会回滚,对于第一块代码,有两种方法
第一种是改变逻辑,先判断是不是为 1
第二种是把 begin 和 rescue 之间的代码写在事务里面User.transaction do ... end
首先你的逻辑有问题吧,删除了再判断,然后来一个cant delete last user
!!!
其次:
def destroy
begin
@user.destroy
flash[:notice] = "User #{@user.name} deleted"
if User.count.zero? # 1 如果这里确实为ture
raise 'cant delete last user' # 2 那么这里异常会调到rescue
end # 3
rescue StandardError => e # rescue Exception => e
flash[:notice] = e.message # 那么这里就会执行
end
respond_to do |format| # 正常执行
format.html { redirect_to users_url }
format.json { head :no_content }
end
end
我猜测是不是 StandardError 的问题,报什么错你没说。换顶层的Exception => e
试下
simple_form 没用过
你可以谷歌下省市区级联菜单
1.可以全部前段搞定,见 qq 的 ip 查询那个页面的做法
2.可以把省市区保存到后台文件或者数据库,然后 ajax
#3 楼 @42thcoder 可以直接收到 A 的消息, 然后转发给 B 的.
这里就是关键,我可能转发给 B, 也可能转发给 BCDEF......问题就是怎么去转发,我可以识别是哪个发来的 (在 message 里面带 username).但是我看到的 websocket 实现除了 socket.io 有from
和to
,其他都没有。
#1 楼 @zhang_soledad 谢谢。我的目的其实不是推送。而是 one to one 的聊天。如果用 pub/sub 实现那就是 1:1,我觉得这样做不值得。换句话说,我想用 websocket 或者 amqp 等其他一些协议来实现 1 对 1 的聊天。
name = name.encode('gb2312', 'utf-8')
看你需求罗,如果以后不直接修改 markdown,就都可以,如果需要修改,那就后台。
gorails.com 有一节专门讲这个,jquery-ujs 那一节,具体的不在电脑操作不便。
Atom编辑器, 可以带你装X, 不能带你飞
预备加上
我找了下,首先查找 libmysqlclient.so.16 文件,如果有就ldd
,没有就安装他,如下:
https://gettechgo.wordpress.com/2012/12/03/failed-dependency-libmysqlcliet-so-16/
原文:
While installing‘mysql’module for PHP 5.4 (yum install php54w-mysql*), I encountered the following error:
Missing Dependency: libmysqlclient.so.16(libmysqlclient_16) is needed by package php-mysql-package-version
The issue was due to the “Missing Dependency” and a library called “libmysqlclient.so.16″ was required.
To resolve this, I downloaded a “compat” rpm, and installed all the different versions of libmysqlclient.so.{12,14,15,16}:
Available at: http://downloads.mysql.com/archives/mysql-5.1/MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm
wget "http://downloads.mysql.com/archives/mysql-5.1/MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm"
rpm -ivh MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm
After that, ‘mysql’ module got installed with PHP 5.4 properly.
#6 楼 @angelfan websocket-rails
project: http://websocket-rails.github.io/
demo: https://github.com/YavorK/websocket-rails-demo-light
之前听说取消了,我去官网看也没有
我意见是 ruby 就别当 java 用了,复杂业务直接 java 的好。另事务是个大问题。
一。网上搜索的,看着靠谱,但是得删除数据库服务器重装 The above problem will be occured because the mysql-devel package is not properly installed in your system. I will be explain the same in Centos of how to fix it. When you try to install that package using,
yum install mysql-devel
somtimes there will be some clash occurs with the existing packages that gets installed if you install the MySql-Administrative tool and MySQL query browser.
In that case, you need to uninstall all the existing mysql2 packages and install it again.
rpm -qa -last | grep -i mysql
yum remove MySQL-server-5.5.27-1.rhel5
yum remove MySQL-client-5.5.27-1.rhel5
yum remove mysql-gui-tools-5.0r12-1rhel4
yum remove mysql-query-browser-5.0r12-1rhel4-a
So, you can uninstall whatever mysql things displayed with rpm -qa as like above.
Then you can install the mysql-server and mysql-client.
yum install mysql-server
yum install mysql-client
Now you do the installation of mysql-devel package.
yum install mysql-devel
Now there is no package clashes and you can able to install the mysql2 gem.
gem install mysql2 -v '0.3.11'
Now your mysql2 gem will be successfully installed and you are good to go.
http://stackoverflow.com/questions/3754662/errors-installing-mysql2-gem-via-the-bundler
二。不用重装,但不知道能不能行
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.27-1.el6.x86_64.rpm
rpm -Uvh MySQL-devel-5.5.27-1.el6.x86_64.rpm
gem install mysql
gem install mysql2
http://stackoverflow.com/questions/12119567/mysql2-gem-installation-fails