夜鸣猪的Ruby On Rails 空间
夜鸣猪 · 共 628 篇文章
rails 3 在route中重定向
Yourapp::Application.routes.draw do #Last route in routes.rb match '*a', :to => 'errors#routing' end NOTE: The "a" is actually a parameter in the Rails 3 Route Globbing technique. For example, if your url was /this-url-does-not-exist, then params[:a] equals "/this-url-does-not-exist". So be as crea…
2012-09-02 09:10 · Ruby On Rails · 评论(0)
quick fix for ubuntu
/home/myuser/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb Gem files will remain installed in /home/myuser/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.12.1 for inspection. Results logged to /home/myuser/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.12.1/./gem_make.out An error occured whi…
2012-08-30 21:56 · Ruby On Rails · 评论(0)
vim gighlight
Error detected while processing function 56_IndentGuidesEnable..indent_guid es#enable..indent_guides#init_script_vars..indent_guides#capture_highlight: line 2: E411: highlight group not found: Normal colorscheme default to .vimrc
2012-08-28 11:22 · 评论(0)
ubuntu手动安装mysql 的一些理解
sudo aptitude install mysql 固然方便,有些时候,还要用源码或者binary安装 一些知识如下: sudo ./scripts/mysql_install_db --user=mysql --ldata=/data/mysql --basedir=. ./bin/mysql: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory sudo aptitude install lib32ncurse…
2012-08-27 07:50 · Mysql · 评论(0)
正则表达式验证 password
#口令要求,必须包含大写或者小写 #必须包含数字 #总共8到40 /^(?=.*\d)(?=.*([a-z]|[a-z]))([\x20-\x7e]){8,40}$/
2012-08-23 23:14 · Ruby On Rails · 评论(0)
在haml的javascript中 调用rails ruby的变量
%html %head :javascript var foo = []; #{ limit = rand(4)+3 array = (0..limit).to_a array.map{ |i| "foo[#{i}] = #{rand(12)};" }.join ' ' } console.log(foo.length); %body 在jquery chart中经常会用到,在controller里生成的json变量给jquery的插件读数据 <html> <head> <script type='text/javascript'> //<![cdata[ var foo = []; foo…
2012-08-17 09:49 · Ruby On Rails · 评论(0)
在rails console里测试routes
Sometimes you need to check what your route helpers are returning, and the "rake routes" task isn't enough. Those helpers are accessible through an instance of the ActionController::Integration::Session class, and at the Rails console there is one instance of this class already available: >> app.cl…
2012-08-10 10:19 · Ruby On Rails · 评论(0)
Scoped anti mass assignment
http://launchware.com/articles/whats-new-in-edge-scoped-mass-assignment-in-rails-3-1 http://ejholmes.github.com/2012/04/22/handling-mass-assignment-with-active-admin.html http://stackoverflow.com/questions/6434215/how-to-seed-a-rails-3-1-app-with-scoped-mass-assignment http://railscasts.com/episode…
2012-08-02 22:34 · Ruby On Rails · 评论(0)
Ruby的try 方法
This is something we’re using on GitHub that I really wish I started using sooner. For lack of a better name, it’s called try(). It works like this: def remove_email(email) emails.find_by_email(email).try(:destroy) end Another example: file_type = file_types.detect { |key,| name.include? key }.try(…
2012-08-02 11:22 · Ruby On Rails · 评论(0)
git tags 使用 远程创建git tags 删除(小抄版)
Reference update 0.5 获取远程tag #my_abc是tag号 git clone http://git.abc.net/git/abc.git git checkout my_abc OR git checkout -b new_branch my_abc update v2 获取远程tag or branch code="java"]$ git ls-remote --heads origin 5b3f7563ae1b4a7160fda7fe34240d40c5777dcd refs/heads/1-2-stable 71926912a127da29530520d43…
2012-08-01 21:13 · Ruby On Rails · 评论(0)
标准coffeescript 调用ajax
$.ajax '/', type: 'GET' dataType: 'html' error: (jqXHR, textStatus, errorThrown) -> $('body').append "AJAX Error: #{textStatus}" success: (data, textStatus, jqXHR) -> $('body').append "Successful AJAX call: #{data}" 单个select的调用 $(document).ready(function() { $('#display_arms').change(function(){ $.…
2012-07-31 10:31 · Ruby On Rails · 评论(0)
mysql gem2 error
Can't connect to MySQL server on '192.168. . ' (111) sudo aptitude install libmysqlclient-dev
2012-07-31 00:22 · Ruby On Rails · 评论(0)
quick fix: ubuntu lib for rails 3.2.7 updated fresh install
if you are using webkit-driver for selenium in your rails project under ubuntu 12.04 lts you may need follow lib sudo aptitude install libqt4-dev libqtwebkit-dev Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavaila…
2012-07-31 00:20 · Ruby On Rails · 评论(0)
rails begin exception retry
I am not certain whether the ability to retry a code block when encountering exceptions was a feature available in Ruby, but I certainly couldn’t find anything on that topic (what I did find were mostly about the retry keyword for iterator loops). Before you ask why I need this, the motivation for …
2012-07-29 02:34 · 评论(0)
配置Mountain Lion和Homebrew RVM
Install XCode 4.4 into /Applications Get it from http://developer.apple.com. You will not be able to submit apps to any stores using this XCode version, so turn away if that is something you might want to do. Install Command Line Tools In XCode's Preferences > Downloads you can install command line…
2012-07-29 01:03 · Ruby On Rails · 评论(0)