In your command-line run the following commands:
brew doctorbrew update
| threads << Thread.new do ActiveRecord::Base.connection_pool.with_connection do | |
| # needed because otherwise the connection pool can run | |
| # out of connections | |
| t = Thread.current | |
| t[:variable_name] = Model.find_by(column: data) | |
| end | |
| end | |
| joined_threads = threads.map &:join | |
| # do something with the thread local variable |
In your command-line run the following commands:
brew doctorbrew update| # Install | |
| # via http://askubuntu.com/questions/510056/how-to-install-google-chrome | |
| wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
| sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' | |
| sudo apt-get update | |
| sudo apt-get install google-chrome-stable | |
| # Update |
| # | |
| # Install the MYSQL driver | |
| # gem install mysql2 | |
| # | |
| # Ensure the MySQL gem is defined in your Gemfile | |
| # gem 'mysql2' | |
| # | |
| # And be sure to use new-style password hashing: | |
| # http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
| development: |
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
| def valid? version | |
| pattern = /^\d+\.\d+\.\d+(\-(dev|beta|rc\d+))?$/ | |
| raise "Tried to set invalid version: #{version}".red unless version =~ pattern | |
| end | |
| def correct_version version | |
| ver, flag = version.split '-' | |
| v = ver.split '.' | |
| (0..2).each do |n| | |
| v[n] = v[n].to_i |
The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.
The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.