- 浏览: 2077972 次
- 性别:
- 来自: NYC
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
文章列表
#spec/support/deferred_garbage_collection.rb
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f
@@last_gc_run = Time.now
def self.start
GC.disable if DEFERRED_GC_THRESHOLD > 0
end
def self.reconsider
if DEFERRED_GC_THRESHOLD & ...
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name}")
class MyClass
def initialize(dynamic_methods)
@arr = Array.new(dynamic_methods)
@arr.each{|m|
self.class.class_eval do
define_method(m) do |*value|
puts value
end
end
}
end
end
tmp = MyClass.new %w(method1 method2 method3)
tmp ...
method_missing is a well-known tool in the Ruby metaprogramming toolbox. It’s callback method you can implement that gets called when a object tries to call a method that’s, well, missing. A well known example of this is ActiveRecord dynamic finders. For example, if your User has an email attribute, ...
sudo apt-get install libmysql-ruby libmysqlclient-dev
For anyone coming to this question recently: the answer has changed in Rails 3.2, because they've changed how they implement reload! Where in earlier version the irb commands were added as methods to Object, now they are added to IRB::ExtendCommandBundle to avoid polluting the global namespace.
W ...
#need pg in Gemfile
#sqlite3 in dev
1) gem install heroku
2) heroku login
3) heroku create
4) heroku apps:rename newapp
[https://devcenter.heroku.com/articles/renaming-apps]
5) git push heroku master
[https://devcenter.heroku.com/articles/git]
6) heroku run rake db:version
[htt ...
update(05/13/2013)
rbenv:
解决方案:
gem install debugger-linecache -- --with-ruby-include=/home/user/.rbenv/versions/1.9.3-p392
gem install ruby-debug19 -- --with-ruby-include=/home/user/.rbenv/versions/1.9.3-p392
引用
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. ...
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
#rails3
MyApp::Application.config.custom_config_variable = :my_config_setting
or
Rails.configuration.custom_config_variable = :my_config_setting
#need initialization files or the environment.rb
YourApp::Ap ...
非常有用的相关资料
UPDATE(05/06/2013):
still works fine for MAC
modify
/usr/local/var/postgres/postgresql.conf
get localhost works
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log restart
还是说brew安装,之前之后的事
1. 用brew安装postgresql,很忌讳rvm的gcc,要用xcode的command line
2. brew装完要设置路径,就是loc ...
引用
psql: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
引用
createuser: could not connect to database postgres: could not connect to server: Permission denied
Is the ...
UPDATE(2013/06/01)
brew services restart postgresql
psql -U kenlu -h localhost -d postgres
几个重要说明:
1. mac 下brew安装后要initdb
2. 启动后,默认管理员是系统当前帐户
3. psql不认的时候,就是brew的路径问题(见下代码)
4. brew装的重启,启动什么的用brew services
在ubuntu下完全不同sudo aptitude 安装后,不许要initdb只要
sudo -u postgres psql template1
template1=# CR ...
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones ...
update(05/13/2013)
ubuntu only
ALTER USER postgres with encrypted password 'your_password';
#/etc/postgresql/9.1/main/postgresql.conf
#localhost
Locate the line #listen_addresses = 'localhost' and change it to:
listen_addresses = 'localhost'
sudo -u postgres psql template1
\du list user
...
Update:11/09/2012
有同鞋求摘要如下:
遇到类似错误,在使用或调用SSL的API时候, RVM怎么用呢
引用
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
Gem::RemoteFetcher::FetchError: SSL_connect returned= ...