~/.gemrcの作成場所は?
こちらです(Windows XP/2000の場合)↓
C:\Documents and Settings\your_name\.gemrc
どうも、RadRailsが雛形を置いてくれてたようです。
お約束どおり、"--no-ri --no-rdoc"を追加しました。
:verbose: true :sources: - http://gems.rubyforge.org/ - http://gems.github.com :benchmark: false :backtrace: false :update_sources: true :bulk_threshold: 1000 install: --no-ri --no-rdoc update: --no-ri --no-rdoc
ruby 1.9.1p129&Rails 2.3.4でWEBrickが使えない?
見事にSegmentation fault。orz
一応、報告しておきました↓
http://redmine.ruby-lang.org/issues/show/2073
=> Booting WEBrick => Rails 2.3.4 application starting on http://0.0.0.0:80 C:/Ruby/lib/ruby/gems/1.9.1/gems/ruby-debug-base-0.10.3-x86-mswin32/lib/ruby_debug.so: [BUG] Segmentation fault ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32] -- control frame ---------- c:0038 p:-7037552 s:0143 b:0143 l:000142 d:000142 TOP c:0037 p:---- s:0141 b:0141 l:000140 d:000140 CFUNC :require c:0036 p:0012 s:0137 b:0137 l:000126 d:000136 BLOCK C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0035 p:0055 s:0135 b:0135 l:000134 d:000134 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521 c:0034 p:0041 s:0127 b:0127 l:000126 d:000126 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0033 p:0011 s:0121 b:0121 l:000120 d:000120 TOP C:/Ruby/lib/ruby/gems/1.9.1/gems/ruby-debug-base-0.10.3-x86-mswin32/lib/ruby-debug-base.rb:1 c:0032 p:---- s:0119 b:0119 l:000118 d:000118 FINISH c:0031 p:---- s:0117 b:0117 l:000116 d:000116 CFUNC :require c:0030 p:0012 s:0113 b:0113 l:000102 d:000112 BLOCK C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0029 p:0055 s:0111 b:0111 l:000110 d:000110 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521 c:0028 p:0041 s:0103 b:0103 l:000102 d:000102 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0027 p:0059 s:0097 b:0097 l:000096 d:000096 TOP C:/Ruby/lib/ruby/gems/1.9.1/gems/ruby-debug-0.10.3/cli/ruby-debug.rb:5 c:0026 p:---- s:0095 b:0095 l:000094 d:000094 FINISH c:0025 p:---- s:0093 b:0093 l:000092 d:000092 CFUNC :require c:0024 p:0012 s:0089 b:0089 l:000078 d:000088 BLOCK C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0023 p:0055 s:0087 b:0087 l:000086 d:000086 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521 c:0022 p:0041 s:0079 b:0079 l:000078 d:000078 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156 c:0021 p:0014 s:0073 b:0073 l:000063 d:000072 BLOCK C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:7 c:0020 p:0021 s:0068 b:0068 l:000067 d:000067 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/reporting.rb:11 c:0019 p:0011 s:0064 b:0064 l:000063 d:000063 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:5 c:0018 p:0019 s:0060 b:0060 l:000059 d:000059 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/rails/rack/debugger.rb:7 c:0017 p:---- s:0056 b:0056 l:000055 d:000055 FINISH c:0016 p:---- s:0054 b:0054 l:000053 d:000053 CFUNC :new c:0015 p:0020 s:0050 b:0050 l:000ad0 d:000049 LAMBDA C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:37 c:0014 p:---- s:0047 b:0047 l:000046 d:000046 FINISH c:0013 p:---- s:0045 b:0045 l:000044 d:000044 CFUNC :call c:0012 p:0014 s:0041 b:0041 l:000026 d:000040 BLOCK C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56 c:0011 p:---- s:0037 b:0037 l:000036 d:000036 FINISH c:0010 p:---- s:0035 b:0035 l:000030 d:000034 IFUNC :instance_eval c:0009 p:---- s:0033 b:0033 l:000032 d:000032 CFUNC :each c:0008 p:---- s:0031 b:0031 l:000030 d:000030 CFUNC :inject c:0007 p:0094 s:0027 b:0027 l:000026 d:000026 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56 c:0006 p:0722 s:0023 b:0023 l:002648 d:002648 TOP C:/Ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/commands/server.rb:95 c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require c:0003 p:0038 s:0006 b:0006 l:000ab4 d:00045c EVAL script/server:3 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:000ab4 d:000ab4 TOP <main>:282 --------------------------- -- Ruby level backtrace information----------------------------------------- C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/ruby-debug-base-0.10.3-x86-mswin32/lib/ruby-debug-base.rb:1:in `<top (required)>' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/ruby-debug-0.10.3/cli/ruby-debug.rb:5:in `<top (required)>' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:7:in `block in require_library_or_gem' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem' C:/Ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/rails/rack/debugger.rb:7:in `initialize' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:37:in `new' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:37:in `block in use' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56:in `call' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56:in `block in to_app' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56:in `each' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56:in `inject' C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:56:in `to_app' C:/Ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/commands/server.rb:95:in `<top (required)>' script/server:3:in `require' script/server:3:in `<main>' [NOTE] You may encounter a bug of Ruby interpreter. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
確認画面を作ってみた
http://kurobox.dnsalias.net/weblog/?p=29を見よう見まねで、確認画面を作ってみた。
お約束どおり、プロジェクトの作成
Welcome to the Rails Shell. This view is meant for advanced users and command line lovers as a text-based way to run rails commands such as: rails, script/generate, script/plugin, gem, rake, etc. This shell can replace the functionality of the Rake Tasks, Rails Plugins, and generators views. >rails confirm_demo exists create app/controllers create app/helpers create app/models 【中略】 create log/server.log create log/production.log create log/development.log create log/test.log
コントローラの作成
>cd confirm_demo Switched current working project to confirm_demo >ruby script/generate controller Disp exists app/controllers/ exists app/helpers/ create app/views/disp exists test/functional/ create test/unit/helpers/ create app/controllers/disp_controller.rb create test/functional/disp_controller_test.rb create app/helpers/disp_helper.rb create test/unit/helpers/disp_helper_test.rb
DispコントローラにはhelloRailsとconfirmの2つのアクションを作る。
- confirm_demo/app/controllers/disp_controller.rb
class DispController < ApplicationController def helloRails end def confirm @text1 = params[:member][:name] @text2 = params[:member][:addr] end end
入力画面のビューの作成
- confirm_demo/app/views/helloRails.html.erb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Railsによるフォームサンプル</title> </head> <body> <h1> お問い合わせフォームサンプル </h1> <% form_for :member, :url => {:controller => 'disp',:action => 'confirm' } do |f| %> 名前:<%= f.text_field :name %><br/> 住所:<%= f.text_field :addr %><br/> <br/> <%= f.submit '送信' %> <%end%> </body> </html>
確認画面のビューの作成
- confirm_demo/app/views/confirm.html.erb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Railsによるフォームサンプル</title> </head> <body> <h1> お問い合わせフォームサンプル </h1> <br/> 入力した名前:<%= h @text1 %><br/> 入力した住所:<%= h @text2 %><br/> <br/> <%= link_to '戻る', :controller => 'disp', :action => 'helloRails' %> </body> </html>
#h()を付けてサニタイズ対策してみた。
i18n_generatorsで「正しい」楽チン日本語化
ごめんなさい。m(_ _)m
http://d.hatena.ne.jp/babydaemons/20090824/1251103946で書いたlabelのi18n化のやり方は間違ってました。ごめんなさい。m(_ _)m
【追記】
i18n_generator - Rubyとか Illustratorとか SFとか折紙とかに詳しい解説があります。Ruby On Rails 国際標準化機能 I18n その2にも解説があります。
<p> <%= f.label User.human_attribute_name('family_name') %><br /> <%= f.text_field :family_name %> </p>
とかやっちゃうと、
<p> <label for="user_姓">姓</label><br /> <input id="user_family_name" name="user[family_name]" size="30" type="text" /> </p>
こうレンダリングされます。orz
正しいやり方
http://blog.imishin.com/2009/01/09/rails-2-2-i18n/にあります。私のほうでなんちゃってplugin化してみました。RAILS_ROOTで展開してください。
上記の書き換えをやらなくてもラベルがi18n化されます。こうじゃないとDRYじゃないよね。orz
#だれか正しいpluginの作り方と公開の仕方をご教授ください。m(_ _)m
基礎Ruby on Rails (IMPRESS KISO SERIES)
- 作者: 黒田努,佐藤和人
- 出版社/メーカー: インプレスジャパン
- 発売日: 2007/10/25
- メディア: 単行本
- 購入: 8人 クリック: 106回
- この商品を含むブログ (42件) を見る
SciTEの日本語化
基本:まずは日本語表示をおkにする
SciTEを起動して、メニューで[Options]→[Open Global Options File]から下記のように変更する。
--- SciTEGlobal.properties.orig 2009-08-26 11:50:47.890625000 +0900 +++ SciTEGlobal.properties 2009-08-26 11:20:34.125000000 +0900 @@ -224,11 +224,11 @@ # Internationalisation # Japanese input code page 932 and ShiftJIS character set 128 -#code.page=932 -#character.set=128 +code.page=932 +character.set=128 # Unicode #code.page=65001 -code.page=0 +#code.page=0 #character.set=204 # Required for Unicode to work on GTK+: #LC_CTYPE=en_US.UTF-8
こちらを参照。
ただしこの状態でUTF-8なソースコードを読ませると、バケバケです。orz
RailsでWebアプリケーションを開発する場合は、UTF-8なソースを書くでしょうからこんな感じです↓
--- SciTEGlobal.properties.orig 2009-08-26 11:50:47.890625000 +0900 +++ SciTEGlobal.properties 2009-08-26 14:56:21.906250000 +0900 @@ -225,10 +225,10 @@ # Internationalisation # Japanese input code page 932 and ShiftJIS character set 128 #code.page=932 -#character.set=128 +character.set=128 # Unicode -#code.page=65001 -code.page=0 +code.page=65001 +#code.page=0 #character.set=204 # Required for Unicode to work on GTK+: #LC_CTYPE=en_US.UTF-8
こちらを参照。
One-Click Ruby Installerインストール後の手動Railsインストールでハマル(on Cygwin)
現象
教科書どおり、rubygemsのアーカイブを展開してsetup.rbを実行したら下記のように怒られました。
babydaemons@mypc /tmp $ tar xvzpf rubygems-1.3.5.tgz rubygems-1.3.5/ rubygems-1.3.5/.autotest 【中略】 rubygems-1.3.5/util/gem_prelude.rb.template babydaemons@mypc /tmp $ cd rubygems-1.3.5/ babydaemons@mypc /tmp/rubygems-1.3.5 $ ruby setup.rb ruby: no such file to load -- ubygems (LoadError)
とりあえずの逃げ
babydaemons@mypc /tmp/rubygems-1.3.5 $ RUBYOPT=; export RUBYOPT babydaemons@mypc /tmp/rubygems-1.3.5 $ ruby setup.rb RubyGems 1.3.5 installed 【中略】 RubyGems installed the following executables: /usr/bin/gem
抜本対策
vi /etc/profileして下記を追記しておきましょうw
# see, http://d.hatena.ne.jp/daftbeats/20070531/1180613965 # see, http://d.hatena.ne.jp/argius/20071013/1192297580 RUBYOPT= export RUBYOPT
仕上げに
railsをインストール。
babydaemons@mypc /tmp/rubygems-1.3.5 $ gem install rails --include-dependencies INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Successfully installed activeresource-2.3.3 Successfully installed rails-2.3.3 2 gems installed Installing ri documentation for activeresource-2.3.3... Installing ri documentation for rails-2.3.3... Installing RDoc documentation for activeresource-2.3.3... Installing RDoc documentation for rails-2.3.3...
i18n_generatorsで楽チン日本語化
ActiveHeartを使おうとぐぐってみたら、2009-02-15 - 大人になったら肺呼吸にて非推奨とのこと。そこからhttp://ukstudio.jp/2008/11/rails_22_i18n/をたどって、http://blog.dio.jp/2008/11/22/japanizing-rails-2-2-by-i18n-generatorsにてRails-2.2のi18n対応のお勉強をしました。
お手本環境はおそらくLinuxですが(sudoやってるから)、こっちはマシン台数&CPUパワーの制約でWindowsです。orz
#Cygwinでやればよかったかもとちょっと後悔。orz
【追記】
i18n_generator - Rubyとか Illustratorとか SFとか折紙とかに詳しい解説があります。Ruby On Rails 国際標準化機能 I18n その2にも解説があります。
まず、i18n_generatorsをインストール。
[C:\src] $ gem so -a http://gems.github.com http://gems.github.com added to sources [C:\src] $ gem i amatsuda-i18n_generators Successfully installed locale-2.0.4 Successfully installed gettext-2.0.4 Successfully installed amatsuda-i18n_generators-0.6.0 3 gems installed Installing ri documentation for locale-2.0.4... Installing ri documentation for gettext-2.0.4... Installing RDoc documentation for locale-2.0.4... Installing RDoc documentation for gettext-2.0.4...
普通にプロジェクトを作成して、change directory。
[C:\src] $ rails test090824d create create app/controllers create app/helpers create app/models create app/views/layouts 【中略】 create log/test.log [C:\src] $ cd test090824d
ここで、i18n_generatorsでアプリケーションの雛形を作成。
[C:\src\test090824d] $ ruby script\generate i18n_scaffold user first_name:string last_name:string birthday:dateblood_type:integer zip_code:string address1:string address2:string exists app/models/ exists app/controllers/ exists app/helpers/ 【中略】 create db/migrate create db/migrate/20090824083020_create_users.rb
SQLiteのDBを作成。
[C:\src\test090824d] $ rake db:migrate (in C:/src/test090824d) == CreateUsers: migrating ==================================================== -- create_table(:users) -> 0.2180s == CreateUsers: migrated (0.2180s) ===========================================
日本語のリソースを生成。勝手に翻訳してくれる!!!*1
[C:\src\test090824d] $ ruby script\generate i18n ja debug updating environment.rb ... debug fetching ja.yml from rails-i18n repository... exists config/locales update config/environment.rb create config/locales/ja.yml debug 1 models found. debug 27 translation keys found in views. debug translating activerecord.models.user ... debug translating activerecord.attributes.user.last_name ... debug translating activerecord.attributes.user.first_name ... debug translating activerecord.attributes.user.birthday ... debug translating activerecord.attributes.user.zip_code ... debug translating activerecord.attributes.user.blood_type ... debug translating activerecord.attributes.user.address1 ... debug translating activerecord.attributes.user.address2 ... debug translating railties.scaffold.editing ... debug translating railties.scaffold.show ... debug translating railties.scaffold.back ... debug translating railties.scaffold.new ... debug translating railties.scaffold.listing ... debug translating railties.scaffold.edit ... failed to translate "user" into "ja" language. failed to translate "last_name" into "ja" language. debug took 217.953 secs to translate. create config/locales/translation_ja.yml
翻訳されたtranslation_ja.ymlを覗いてみる。全自動だからイマイチな訳も当然含まれるが、ここまでやってくれるのかとメチャクチャ感動!!!
ja: activerecord: models: user: "user" #g attributes: user: first_name: "名前" #g last_name: "last_name" #g birthday: "誕生日" #g blood_type: "血液型" #g zip_code: "郵便番号" #g address1: "アドレス" #g address2: "住所2" #g railties: scaffold: editing: "編集" #g show: "見せる" #g back: "後ろの" #g listing: "一覧" #g new: "新しい" #g edit: "編集" #g
とりあえず、直す。
ja: activerecord: models: user: "ユーザ" #g attributes: user: first_name: "名" #g last_name: "姓" #g birthday: "誕生日" #g blood_type: "血液型" #g zip_code: "郵便番号" #g address1: "住所1" #g address2: "住所2" #g railties: scaffold: editing: "編集" #g show: "参照" #g back: "戻る" #g listing: "一覧" #g new: "新規" #g edit: "編集" #g create: "登録" #g update: "更新" #g destroy: "削除" #g
これで、新規(new.html.erb)と編集(edit.html.erb)を除いて完全に日本語化された。new.html.erbとedit.html.erbが不完全なのはなんでだ?
#f.labelの引数にUser.human_attribute_name()が付いてない。
- new.html.erb
<h1><%= translate(:new, :default => "New {{model}}", :model => User.human_name, :scope => [:railties, :scaffold]) %></h1> <% form_for(@user) do |f| %> <%= f.error_messages %> <p> <%= f.label :first_name %><br /> <%= f.text_field :first_name %> </p> <p> <%= f.label :last_name %><br /> <%= f.text_field :last_name %> </p> <p> <%= f.label :birthday %><br /> <%= f.date_select :birthday %> </p> <p> <%= f.label :blood_type %><br /> <%= f.text_field :blood_type %> </p> <p> <%= f.label :zip_code %><br /> <%= f.text_field :zip_code %> </p> <p> <%= f.label :address1 %><br /> <%= f.text_field :address1 %> </p> <p> <%= f.label :address2 %><br /> <%= f.text_field :address2 %> </p> <p> <%= f.submit translate(:create, :default => "Create", :scope => [:railties, :scaffold]) %> </p> <% end %> <%= link_to translate(:back, :default => 'Back', :scope => [:railties, :scaffold]), users_path %>
- edit.html.erb
<h1><% translate(:editing, :default => "Editing {{model}}", :model => User.human_name, :scope => [:railties, :scaffold]) %></h1> <% form_for(@user) do |f| %> <%= f.error_messages %> <p> <%= f.label :first_name %><br /> <%= f.text_field :first_name %> </p> <p> <%= f.label :last_name %><br /> <%= f.text_field :last_name %> </p> <p> <%= f.label :birthday %><br /> <%= f.date_select :birthday %> </p> <p> <%= f.label :blood_type %><br /> <%= f.text_field :blood_type %> </p> <p> <%= f.label :zip_code %><br /> <%= f.text_field :zip_code %> </p> <p> <%= f.label :address1 %><br /> <%= f.text_field :address1 %> </p> <p> <%= f.label :address2 %><br /> <%= f.text_field :address2 %> </p> <p> <%= f.submit translate(:update, :default => "Update", :scope => [:railties, :scaffold]) %> </p> <% end %> <%= link_to translate(:show, :default => 'Show', :scope => [:railties, :scaffold]), @user %> | <%= link_to translate(:back, :default => 'Back', :scope => [:railties, :scaffold]), users_path %>
これ以下は間違ってます。こちらを参照願います。m(_ _)m
両方とも直してみる。
- new.html.erb
<h1><%= translate(:new, :default => "New {{model}}", :model => User.human_name, :scope => [:railties, :scaffold]) %></h1> <% form_for(@user) do |f| %> <%= f.error_messages %> <p> <%= f.label User.human_attribute_name('first_name') %><br /> <%= f.text_field :first_name %> </p> <p> <%= f.label User.human_attribute_name('last_name') %><br /> <%= f.text_field :last_name %> </p> <p> <%= f.label User.human_attribute_name('birthday') %><br /> <%= f.date_select :birthday %> </p> <p> <%= f.label User.human_attribute_name('blood_type') %><br /> <%= f.text_field :blood_type %> </p> <p> <%= f.label User.human_attribute_name('zip_code') %><br /> <%= f.text_field :zip_code %> </p> <p> <%= f.label User.human_attribute_name('address1') %><br /> <%= f.text_field :address1 %> </p> <p> <%= f.label User.human_attribute_name('address2') %><br /> <%= f.text_field :address2 %> </p> <p> <%= f.submit translate(:create, :default => "Create", :scope => [:railties, :scaffold]) %> </p> <% end %> <%= link_to translate(:back, :default => 'Back', :scope => [:railties, :scaffold]), users_path %>
- edit.html.erb
<h1><% translate(:editing, :default => "Editing {{model}}", :model => User.human_name, :scope => [:railties, :scaffold]) %></h1> <% form_for(@user) do |f| %> <%= f.error_messages %> <p> <%= f.label User.human_attribute_name('first_name') %><br /> <%= f.text_field :first_name %> </p> <p> <%= f.label User.human_attribute_name('last_name') %><br /> <%= f.text_field :last_name %> </p> <p> <%= f.label User.human_attribute_name('birthday') %><br /> <%= f.date_select :birthday %> </p> <p> <%= f.label User.human_attribute_name('blood_type') %><br /> <%= f.text_field :blood_type %> </p> <p> <%= f.label User.human_attribute_name('zip_code') %><br /> <%= f.text_field :zip_code %> </p> <p> <%= f.label User.human_attribute_name('address1') %><br /> <%= f.text_field :address1 %> </p> <p> <%= f.label User.human_attribute_name('address2') %><br /> <%= f.text_field :address2 %> </p> <p> <%= f.submit translate(:update, :default => "Update", :scope => [:railties, :scaffold]) %> </p> <% end %> <%= link_to translate(:show, :default => 'Show', :scope => [:railties, :scaffold]), @user %> | <%= link_to translate(:back, :default => 'Back', :scope => [:railties, :scaffold]), users_path %>
これでnewとeditのラベルも日本語化された。
最初からこんなソースを吐いてほしいんだけど、どう変更すればいいんだろう?>i18n_generators
*1:うちのネットワーク環境のせいかも知れませんが、オンラインで辞書を引いているみたいで時間が掛かります。