ITeye博客

夜鸣猪的Ruby On Rails 空间

夜鸣猪 · 共 628 篇文章

mysql root 远程权限

sudo apt-get install mysql-server Ubuntu installs Mysql at /etc/mysql/ by default. Now we need to set a root password. mysql -u root mysql> SET PASSWORD FOR 'ROOT'@'LOCALHOST" > = PASSWORD('new_password'); Now while we’re still here, we’ll create a new HOST for root and allow root to login from any…

2012-07-17 20:47 · Ruby On Rails · 评论(0)

为什么github总提示输入用户名和密码,如何修改

git credential-osxkeychain# Test for the cred helper # git: 'credential-osxkeychain' is not a git command. See 'git --help'. curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain# Download the helper chmod u+x git-credential-osxkeychain# Fix the permissions on the…

2012-07-17 10:55 · Ruby On Rails · 评论(0)

rvm use 的错误

RVM is not a function, selecting rubies with 'rvm use ...' will not work ➜ ~ rvm list rvm rubies ruby-1.9.2-p290 [ x86_64 ] ruby-1.9.3-p0 [ x86_64 ] ➜ ~ rvm use ruby-1.9.3-p0 RVM is not a function, selecting rubies with 'rvm use ...' will not work. PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for sc…

2012-07-16 22:02 · Ruby On Rails · 评论(0)

加载rails环境的通常办法

#!/usr/bin/env ruby # Set your environment here. ENV["rails_env"] ||= "production" require File.dirname(__FILE__) + "/../../config/environment" puts "Rails was loaded!" rb /lib/tasks/file.rb RAILS_ENV=development 通常用runner rails runner your_script_here.rb

2012-07-16 21:19 · Ruby On Rails · 评论(0)

utf8 ruby1.9

invalid byte sequence in utf-8 mysql In Ruby 1.9.3 is possible to use String.encode to "ignore" the invalid UTF-8 sequences. Here is a snippet that will work both in 1.8 (iconv) and 1.9 (String#encode) : require 'iconv' unless String.method_defined?(:encode) if String.method_defined?(:encode) file_…

2012-07-13 01:57 · Linux · Ruby On Rails · 评论(0)

Rails 3 Ruby 1.9.3 utf-8 编码错误

invalid byte sequence in utf-8 解决的办法是,改my.cnf default-character-set = utf8 default-collation = utf8_general_ci 问题是mysql 5.5修改了参数名 character_set_server = utf8 collation_server = utf8_general_ci This is the associated launchpad bug report: https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/9581…

2012-07-12 04:27 · 评论(0)

has_many relation的几种类型

updated: 06/30/2013 0.1 image/video attach to news/article project url class Article < ActiveRecord::Base has_many :attachable_entities, as: :entity has_many :attachables, through: :attachable_entities, source: :attachable, source_type: Image end class AttachableEntity < ActiveRecord::Base belongs_…

2012-06-25 20:43 · Ruby On Rails · 评论(1)

gem安装mysql2 出现编译问题

sudo apt-get install libmysql-ruby libmysqlclient-dev Installing mysql2 (0.3.11) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /home/livegamer/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb checking for rb_thread_blocking_region()... yes c…

2012-05-21 21:44 · Ruby On Rails · 评论(0)

soft delete activerecord

https://github.com/winton/acts_as_archive https://github.com/airblade/paper_trail

2012-05-09 01:52 · 评论(0)

VIM下跳转的区别

VIM在开tag和jumplist的时候有几个差别 经常用的几个 Press Ctrl-O to jump back to the previous (older) location. Press Ctrl-I (same as Tab) to jump forward to the next (newer) location. Ctrl-] gf CTRL-T is working with tags stack CTRL-O is working with jumplist

2012-05-06 00:33 · Linux · 小工具 · 评论(0)

disable asset console log

1. config.assets.debug = false in config/enviroments/development.rb 2. rake assets:precompile. ################################# config.assets.logger = nil ############################solution III if Rails.env.development? Rails.application.assets.logger = Logger.new('/dev/null') Rails::Rack::Logge…

2012-05-03 21:59 · Ruby On Rails · 评论(0)

rails 3.2 debugger error

No source for ruby-1.9.3-p194 provided with debugger-ruby_core_source gem. gem install debugger -v 1.1.3 原因: debugger-ruby_core_source1.1.2 and debugger-linecache1.1.1 凑合看吧,呵呵

2012-05-03 21:52 · Ruby On Rails · 评论(0)

to_query

params = { :a => "http://google.com", :b => 123 } url = "http://example.com?#{params.to_query}" <%= link_to 'Link', params.merge({:per_page => 20}) %>

2012-05-03 00:18 · 评论(0)

VIM ctags setup ack

reference ctags --extra=+f --exclude=.git --exclude=log --exclude=coverage --exclude=public/assets -R * /home/ken/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/* ctags --extra=+f --exclude=.git --exclude=log --exclude=coverage --exclude=public/assets -R * `rvm gemdir`/gems/* 再再更新:2012/10/8 ub…

2012-04-17 22:13 · RubyOnRails · 评论(0)

shell command

ls -l . | egrep -c '^d' ls -l . | egrep -c '^-' 统计个数

2012-04-11 21:42 · Linux · 评论(0)