Rails 3.2 sports many new features including automatic explain queries, tagged logging, key-value store in Active Record, improved migration generator and more. Learn all about these new features in this episode.
Ryan Batesが最近Twitterで、Railsアプリケーションの開発モード(development mode)で、依存するバックグラウンドプロセスを管理する最善の方法は何かと質問を投げかけました。何人かがForemanを推奨していたので、今回のエピソードで紹介します。 例えばRyanのGoVsGoアプリケーションを開発に利用するには、事前にいくつかのバックグラウンドプロセスを起動する必要があります。この中には、Beanstalkd、script/workerプロセス、Fayeサーバが含まれます。開発でこのアプリケーションを使用するたびに、これらすべての起動作業が発生します。これらのプロセスすべてを簡単に管理する方法があればとても便利でしょう。そこでForemanの登場です。 Foremanのインストールと使用 Foremanはgemの形で提供され、通常の方法でインストールします。
namespace :db do desc "Erase and fill database" task :populate => :environment do require 'populator' require 'faker' [Category, Product, Person].each(&:delete_all) Category.populate 20 do |category| category.name = Populator.words(1..3).titleize Product.populate 10..100 do |product| product.category_id = category.id product.name = Populator.words(1..5).titleize product.description = Populator.sen
Bullet will notify you of database queries that can potentially be improved through eager loading or counter cache column. A variety of notification alerts are supported.
開発しているRailsアプリケーションの動きが少し遅くなり始めたとしましょう。パフォーマンスを最適化しなければいけないところですが、その前にプロファイリングツールを実行してボトルネックを見つけておく方がいいでしょう。プロファイリングツールは多くの種類がありますが、今回のエピソードではMiniProfilerを紹介します。このツールは元々は.Netの開発環境用に作られたものですが、最近Ruby向けに移植され、Railsアプリケーションのプロファイリングのための優れたツールとなっています。アプリケーションにMiniProfilerを追加するのは簡単です。gemfileにgemを追加してbundleコマンドを実行してインストールを行なうだけです。
attr_writer :current_step validates_presence_of :shipping_name, :if => lambda { |o| o.current_step == "shipping" } validates_presence_of :billing_name, :if => lambda { |o| o.current_step == "billing" } def current_step @current_step || steps.first end def steps %w[shipping billing confirmation] end def next_step self.current_step = steps[steps.index(current_step)+1] end def previous_step self.curr
class ProductsController < ApplicationController helper_method :sort_column, :sort_direction def index @products = Product.order(sort_column + " " + sort_direction) end # ... private def sort_column Product.column_names.include?(params[:sort]) ? params[:sort] : "name" end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" end end
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く