RailsのWebアプリケーションを英語化(多言語化)をサポートしてくれるGem「i18n」の紹介です。 🎂 i18nのベーシックな使い方デフォルトの言語を日本語にするには、config/application.rbの次のように指定します。
Capistrano3で快適なデプロイ生活を目指しています。Railsで定数設定ファイルをgitから外して管理する方法。と組あわせれば、最高なデプロイ生活が待っていること間違い無しです。 が、Capistrano3のまとまった情報があまり手に入らず(Capistrano2とどっちかよくわからんし)、導入の際にかなり苦労したので、インストールから設定までをさらしておきます。 環境: Ruby 2.0.0-p247 Rails 4.0.0 Apache Passenger Server:CentOS6.4 公開鍵認証設定済み Capistranoとは Rubyでできたソフトウェアデプロイメントツールです。 Capistranoは分散環境へのウェブアプリケーションのソフトウェアデプロイメントを簡素化および自動化するために設計されています。 アプリのデプロイの際に生じるいろいろな作業をコマンドで自
This is a slight modification of code originally written by Alastair Brunton. I recently implemented this for Jetrecord and since Alastair was so generous, I decided to share the love as well. I have changed Alastair’s code to generate a sitemap index file plus sitemap files for each model, all of them gzipped to save on bandwidth. I have also added Capistrano code to copy sitemap files from the p
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
前回の続きです! *パスや名前は適宜読み替えてください。 [gitの準備からCapistranoのセットアップ] 1.本番サーバと配置サーバを分けて用意する。配置用サーバにgitのためのディレクトリを用意する。 SSHで配置用サーバにアクセスして以下。 mkdir -p ~/git/appname.git cd ~/git/appname.git git --bare init 2.配置サーバから本番サーバにアクセスするための公開鍵の設定。 test -e .ssh/id_dsa.pub || ssh-keygen -t dsa cat .ssh/id_dsa.pub >> .ssh/authorized_keys2 3.ドキュメントルートの変更 前回で変更したドキュメントルートを再度変更 vi /etc/httpd/conf/httpd.conf で設定ファイルの Document
本連載の第1回から第3回までは、主にmoonlinxのインフラ技術を説明してきました。今回からはmoonlinxのウェブアプリケーション技術に着目して解説していきたいと思います。 デプロイツール「Capistrano」の魅力 ウェブメディア「moonlinx」では、moonlinx Membership Centerと呼ばれるクリエイター向けの登録制会員サービスを運営しています。これは、デザイナーや音楽活動を行うアーティストをターゲットとしたサービスであり、クリエイター自身の活動をプロモーションするツールとして活用できるサービスです。 このMembership Centerでは、フレームワークとしてRuby on Railsを利用して開発しています。また、PhusionのPassengerを利用して、Apache2上で動作させています。 Railsの運用環境は、MongrelとMongre
Capistrano とは何か。それは、デプロイメントのツールである。 デプロイメントとは何か。Web アプリケーションについて言えば、それは以下のようなタスク全般を指す言葉である。 アプリケーションを本番サーバにインストールすること。あるいは、最新版に更新すること。 Web サーバを起動、再起動、停止すること。 Web サイトをメンテナンス中にすること。あるいは、通常の状態に戻すこと。 世の中に向けて Web アプリケーションを公開しているなら、こうしたタスクは日常茶飯事である。 最初は少し面白いけれど、基本的な退屈な作業だ。 怠惰を美徳とする我々プログラマは、もちろんこんな状況に甘んじるわけにはいかない。 というわけで、Capistrano について研究をしていこうと思う。
Rails 3のルーティングで気になったところについて。いつものメモです。あくまで気になったところなので全部網羅しているわけではありません。あしからず。 基本形 map.connect から match メソッドに変更。オプションも下記のように変更。 # Rails 2 map.connect 'products/:id', :controller => 'products', :action => 'view' # Rails 3 match 'products/:id', :to => 'catalog#view' # :to は省略可能 match "/account" => "account#index" # :controller/:action 形式であればさらに省略可能 match "account/overview" Named Routes asオプションで指定するように
前回の記事でRubyのライブラリーをローカル環境でインストールしてみた。 ただ、これだとgemファイルを集めてくるのが大変である。 そこで、もう一つ便利な方法を見つけた。 それは、すでにRuby環境のととのっているマシンをgemサーバーにするという方法。 この方法を使うと、複数のマシンにRuby環境をセットアップするのも容易になる。 やり方は下記の通り。 gemサーバー側のPCで、下記のコマンドを実行する。 (このPCのIPアドレスを192.168.0.10とする) > gem server RubyライブラリーをインストールしたいPCにて、下記のコマンドを実行する。 (もちろんRubyとgemがインストールされていることが前提) > gem install --remote --source http://192.168.1.10:8808 <パッケージ名> 実行例 以下はgemサーバー
先日作った、Jリーグ予定表APIの続きで、クラブ情報と、スタジアム情報を取得するAPIを作成しようとおもったが、スクレイビングではどうも無理がある。自前でデータ持って出力させるしかなさそうという結論に達した。 で、たまたま、Flex関連のブログみてて「Rails 2.0とFlex 3 beta3でRESTfulなBookmarkアプリを作ろう」ってのがあって、サーバー部分をRuby on Railsで作っていた。しかも、さっくりとコードも書かずにRESTfulなWebAPIが出来る。これは、使えそうって事で、Ruby on Railsの勉強がてら、使ってみることにした。 手始めにクラブ情報を取得するAPIを作ってみます。 基本的な手順は、先のリンクの「Rails 2.0とFlex 3 beta3でRESTfulなBookmarkアプリを作ろう」と同じですが、今回はEclipseのプラグイン
1. memcachedのインストールと環境設定 % yum -y install memcached % /etc/init.d/memcached start % chkconfig memcached on #memcachedのデフォルトポート(11211)を開ける % vi /etc/init.d/iptables % /etc/init.d/iptables restart 2.memcache-clientのインストール % gem install memcache-client 3. railsのmemcachedの設定。environment.rb # Be sure to restart your web server when you modify this file. ... ENV['RAILS_ENV'] ||= 'production' ... # memca
前回は、Rails 3.0 で導入された新しい Gem パッケージ管理ツール Bundler を紹介しました。 今回と次回はユーザー認証の仕組みをアプリケーションに追加します。 Devise Devise を利用すると、メールアドレスとパスワードによるユーザー認証機構を Rails アプリケーションに簡単に組み込むことができます。 現時点(2010/08/30)での最新版は 1.1.2 です。Gemfile を次のように修正してください。 source 'http://rubygems.org' gem 'rails', '3.0.0' gem 'sqlite3-ruby', :require => 'sqlite3' gem 'will_paginate', '3.0.pre' gem 'devise', '1.1.2' 続いて、Bundler でインストールします。 % bundle
Devise の README は懇切丁寧だが、その分クソ長いので、読むのに疲れる。後続のために訳してみることにした。無保証。OAuth2 の部分は飛ばした。長いし。差し迫ったら訳します。 Devise Devise は Warden をベースにした Rails のためのフレキシブルな認証ソリューションです。 Rackベース Rails エンジンに基づいた完全な MVC ソリューション 1回の認証で複数のロールを持たせることができます あなたが必要な部分だけ使えるモジュラー構造というコンセプトに基づいています 以下の11のモジュールで構成されています: Database Authenticatable ユーザーがサインインする時に認証するためにパスワードをデータベースに暗号化し保存します。この認証は POST リクエストまたはBasic認証を通して行われます。 Token Authenti
2010年4月13日、Ruby on Rails 3.0 Beta 3 がリリースされました。 プログラミング言語 Ruby で記述されたもう一つの Web アプリケーション開発フレームワーク Merb との「統合」が発表されたのは、2008年12月23日のことでした。それから1年4ヶ月か経過し、ようやく Rails 3 が生まれ出ようとしています。 Rails 2.3 から何が変わって、何が変わらないのでしょうか。 また、バージョン 3.0 の登場をきっかけに Ruby on Rails の学習に挑戦(あるいは再挑戦)する方は何に気をつければよいでしょうか。 この届いたばかりの「道具箱」を使って、いったい何が作れるのか楽しみですね。 サンプルアプリケーションを少しずつ組み立てながら、一緒に学んでいきましょう。 この連載は、Ruby on Rails 3.0 Beta 3 がリリースされた
Redirecting...でKRAY - みんなで考え、作り、価値を生み出すをやってみた。試行錯誤しながらだったので1時間以上かかったし、この通りにやって1時間でできるかどうかは知らない。 まずはRedirecting...を参考にHerokuを設定する。この記事だとローカルにRails環境を構築するのところで rails heroku-demo ってあるけどそれじゃ作れなくて rails new heroku-demo のようにnewが必要だった。それとbamboo-mri-1.9.2が使えたのでそれ選んだ。他は記事の通り。 続きはKRAY - みんなで考え、作り、価値を生み出すを見ながら。Rails3だと結構違う。 twitter-authのインストールはGemfileに gem 'twitter-auth', :require => 'twitter_auth/engine', :
新着記事 『Ruby on Rails 5.0 初級④: HTMLフォーム(後編)』紙版(ペーパーバック版)が出ます (2017/08/04) WordPress と Ruby on Rails はどこがどう違うのか (2017/04/19) 『実践Ruby on Rails 4』環境構築手順 for macOS(2017年版) (2017/01/24) 『実践Ruby on Rails 4』環境構築手順 for Windows (2017年版) (2017/01/24) Kindle本『Elixir/Phoenix 初級①』を出版しました (2016/11/25) Kindle向けに技術書を3冊出してみて思ったこと (2016/06/08) 問題03の解答と解説 (2016/03/21) 「その他」用のテキスト入力欄を持つ選択式入力欄 (2016/02/08) 問題02の解答と解説 (2
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く