sqlite3 使用jdbc 连接  

Posted by Mindlern in

Jruby 使用jdbc 来连接数据库

首先需要这两个GEM
  jdbc-sqlite3
  activerecord-jdbcsqlite3-adapter

gem install jdbc-sqlite3
gem install activerecord-jdbcsqlite3-adapter

使用默认的rails 脚本生成project
定位到config 目录下的database.yml
修改 adapter 这行为jdbcsqlite3
即可使用数据库了

++++++++++
jruby script/server

http://localhost:3000/rails/info/properties
显示正常就表示OK

e-text 试用感觉太爽了  

Posted by Mindlern in

写ROR,之前一直使用netbeans,因为只能,但是速度真的是很慢。在我的笔记本上,感觉尤为明显,特别是智能提示,找个method,要卡上几秒,不甚爽。关了智能提示吧,那还用netbeans干啥,一大特色功能啊,再加上启动慢,感觉更不好。

就寻到e,号称windows下的textmate,Macos 程序员使用textmate,让我手馋很久了,无奈没有Macos,安装黑苹果,失败了N次,就算了。想来浪费时间安装N次,还是攒钱买个MACBOOK,也当激励自己。

+++++++++回到正题+++++++++
e 试用1天了
感觉真的很棒
代码片段很爽
关键速度很快
小巧 启动好

内置大量bundles
包含RUBY ROR
编写速度上去了

39刀 也不是很贵
比textmate 便宜
如果macbook 没到手
就e用着吧

+++++++++++++++
关于e安装报错问题
看提示 应该是字符造成的
在网上看倒的解决方法

1、都忽略
然后下载textmate bundles 覆盖一边
2、到控制面板-语言区域-有个非unicode 字符显示
中文系统 默认是中国 简体
把它改为英文 美国

需要重启

重启后 安装就不会报错了
完成后再改回去

+++++++++
e 需要cygwin
以这次高级应用
最麻烦的还是这个
国内碰到cygwin
安装非常麻烦
速度真是慢啊
找个新加坡镜像
重试N次还没有安装成功
该死的网速

继续下载中T_T

rails firefox ActionController::InvalidAuthenticityToken  

Posted by Mindlern in

写了个简单的应用(不过是早期阶段

在提交表格到数据库的时候
出现 ActionController::InvalidAuthenticityToken 该错误
GOOGLE 之

原来是rails 防御跨站点攻击检测导致的(还特别是firefox有问题 IE正常...

http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000693

找到上述官方文档

一种解决办法是
整个关闭

在environment.rb中添加
config.action_controller.allow_forgery_protection = false
还有就是到controller 排除
以下是官方给的example

class FooController < ApplicationController

# uses the cookie session store (then you don't need a separate :secret)
protect_from_forgery :except => :index
# uses one of the other session stores that uses a session_id value.
protect_from_forgery :secret => 'my-little-pony', :except => :index
# you can disable csrf protection on controller-by-controller basis:
skip_before_filter :verify_authenticity_token
end
我的情况是create 这action 出错
直接 protect_from_forgery :exception => :create 搞定
这下正常了