最近の投稿
人気のページと投稿
アーカイブ
月 | 火 | 水 | 木 | 金 | 土 | 日 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
AWS, Content Delivery Network and Debian
brewでrails1.9をいれている。結果、
/usr/local/Cellar/ruby/1.9.3-p374/bin/ruby
となっている。
gem install rails
をするとインストールはされるのだがrailsにパスが通ってない。
gem e をすると
$ gem e RubyGems Environment: - RUBYGEMS VERSION: 1.8.23 - RUBY VERSION: 1.9.3 (2013-01-15 patchlevel 374) [x86_64-darwin11.4.2] - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1 - RUBY EXECUTABLE: /usr/local/Cellar/ruby/1.9.3-p374/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p374/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 (以下略)
という具合でEXECUTABLE DIRECTORYにパスは通してある。
結局うまい方法が考えつかず、
$ ln -s /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/bin/rails .
で、いいことにした。
donrailsでつかっているlibxml-rubyとlibxml-xmlrpcをconfig.gemでいれられるようにしていたのだが,そのconfig.gemで指定しても,
Missing these required gems: libxml-ruby libxml-xmlrpc You're running: ruby 1.8.7.160 at /opt/local/bin/ruby rubygems 1.3.4 at /Users/yaar/.gem/ruby/1.8, /opt/local/lib/ruby/gems/1.8
といわれるのでした.
もちろんlibxml-rubyもlibxml-xmlrpcも存在している.
/opt/local/lib/ruby/gems/1.8/gems$ ls libxml-ruby* libxml-ruby-0.8.3: CHANGES RAKEFILE doc/ lib/ test/ LICENSE README ext/ setup.rb libxml-ruby-0.9.7: CHANGES README doc/ lib/ test/ LICENSE Rakefile ext/ setup.rb libxml-ruby-1.1.3: CHANGES README doc/ lib/ test/ LICENSE Rakefile ext/ setup.rb
どうやら
#LibXML Ruby - Dependency of Solr Ruby config.gem "libxml-ruby", :lib=>"xml/libxml", :version=>"~>0.8.3"
こんなかんじで中でよんでる :libの形にあわせて書け,とそういうことらしい.
config.gem "libxml-ruby", :lib=>"xml/libxml" config.gem "libxml-xmlrpc", :lib=>"xmlrpc/client"
に.変更した.これでok
研究でつかってるprogramの前哨戦で,donrailsのrails2.3化を行った.
actionmailer (2.3.2) actionpack (2.3.2) actionwebservice (2.3.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) hpricot (0.8.1) libxml-ruby (1.1.3) libxml-xmlrpc (0.1.5) mocha (0.9.5) mysql (2.7) packet (0.1.15) rails (2.3.2) rake (0.8.4) rubygems-update (1.3.2) will_paginate (2.2.2)
使うのはこんなかんじ.
gem build actionwebservice-2.3.2.gem gem install actionwebservice.gem --local
<%= hidden_field_tag(:session_id_validation, security_token) %>
その数は.
cfardm-2:~/playground/donrails/app/views$ gfind -name \*.rhtml |xargs grep token |wc 35 324 5043
かなり多いな.面倒なので,
module ApplicationHelper def security_token # dummy for 2.3.2 return rand.to_s end
という具合でdummyをいれた.
protect_from_forgery :except => [:catch_trackback, :trackback, :catch_ping]
post :delete_article, :deleteid => {'40000' => '1'} assert_equal "<br>Not exists (no delete):40000", flash[:note2] assert_redirected_to :action => 'manage_article' post :delete_article, :hideid => {'4' => '0'}, :deleteid => nil assert_equal "<br>Hyde status:4 is 0", flash[:note2] assert_redirected_to :action => 'manage_article'
こんなんじで引数を変えて,2つの postを評価しているときには,2つ目のほうには使わない引数には nil を与えるなどしてやらないといかん
NameError (uninitialized constant ApplicationController::AntiSpam): app/controllers/application_controller.rb:199:in `don_is_spam?'
とかでたので,environment.rbをいじった.
config.load_paths += %W( #{RAILS_ROOT}/lib )
ちょっとdonrailsでrails2.3がどんなものかやってみることにした.donrailsはrailsが0.11のころから作っているので,いろんなものをひきずっていて,これで動けばまあ自分の範囲では問題ないから,というのがある.
rake rails:update をまず.
application.rbがapplication_controller.rbにかわった.
次のはまり道
load_missing_constant’: uninitialized constant ActionController::AbstractRequest (NameError)
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::AbstractRequest (NameError) from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing' from /opt/local/lib/ruby/site_ruby/1.8/action_web_service/protocol/abstract.rb:74 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from /opt/local/lib/ruby/site_ruby/1.8/action_web_service/protocol.rb:1 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
このaction_web_serviceの問題か?
http://github.com/datanoise/actionwebservice/tree/masterを見ると2.3.2に対応したとかかいてあるな.
とりあえず plugin install でいれた.
config/environment.rb で
# config.frameworks += [ :action_web_service, :action_mailer ]
というかんじでコメントにしたらokだった.
さて.rake testがまだなので実環境ぶっこみはまだ先だ.
本日の仕事. サーボモータが電力オーバーになるのの対処に時間をとられまくり.
研究とか某所で便利に使っていたActiveScaffoldだが,どうもrailsのversionがあがるにつれて,ついていくのが苦しくなったのか,たんに自分が追えていないのか,バグふみの率が上昇している.これはまずいなあ.
というわけではまっていた
ActiveScaffold :: Describing Records: to_label
Describing Records: to_label
When ActiveScaffold needs to present a string description of a record, it searches through a common list of record properties looking for something that responds. The search set, in order, is: :to_label, :name, :label, :title, and finally :to_s. So if your schema already has one of those fields, it’ll be automatically used. But you can always define a to_label method to customize the string description.
エラー回避 date_select — can’t convert Symbol into String – 税理士業界でSaaS開発をしながら綴る日記
エラー回避 date_select — can’t convert Symbol into String
に書いてあることそのまんまはまってました.>某所のCMS
というわけでfix..
昨日にひきつづき,donrailsをrails2.2.2に対応させるべくいろいろやって,
対応させました.
これで,とりあえずrails2.2対応は終了したのでやっと機能追加にはいれます.
今日やったこと.
DEPRECATION WARNING: truncate takes an option hash instead of separate length and omission arguments. (called from_run_rhtml_app47views47notes47recent_trigger_title_a46rhtml at /Users/yaar/playground/donrails-rails-2.2.2/app/views/notes/recent_trigger_title_a.rhtml:34)
ときたので,
truncate(txt, 76)
となっていたところを
truncate(txt, :length => 76)
にする.
他にも二箇所あったので修正.
donrailsを2.0から2.2に一気にあげなかった理由はこれがなおるかもしれない,と思ったからなのだがやっぱりひっかかった.
(ArgumentError) “Object is not missing constant TagsController!”
こまったな.たしかにdevelopment modeではこれは発生していない.
http://www.nabble.com/forum/Search.jtp?query=activesupport%202.2.2%20load_missing_constant
いろいろ試行錯誤してみると,どうも自分の場合は typoから移植したantispam.rbを models/comment.rbで使っていることにあるようだ.
class Comment < ActiveRecord::Base belongs_to :article validates_presence_of :author validates_length_of :password, :minimum => 4 validates_length_of :body, :minimum => 5 validates_antispam :url validates_antispam :ipaddr validates_antispam :body validates_antispam :author validates_antispam :title (略)
としてるこの validates_antispamをとりあえずどけた.
rails2.0で動いてたdonrailsを2.1に対応させてみた.前もひとつやったけどdonrailsってナニなことをやっているんだなあ,という気にさせられた..
Rendering template within ./MT/notes Rendering notes/./MT/noteslist
というかんでpathの途中に /./ がはいるといかんようだ.
- return File.join(path, theme, filename) + if path == "." + return File.join(theme, filename) ## for rails2.1 + else + return File.join(path, theme, filename) + end
application_helper.rbの中でrenderを呼んでいるときは :inline を指定してやる.
rails2.0のときは
- content += render("shared/attachments/picture", "atta" => atta)
こんなかんじでrender先でつかう変数は"hoge"でくくってやれば使えたが,rails2.1では
+ content += render(:inline => "shared/attachments/picture", :locals => {:atta => atta})
とまあ,:localsを使って指定しなければならない.
app/viewsの下でrenderを呼ぶときは,:template で指定してやる
-<%= render(don_get_theme("shared/category_title_list"), "category" => "donrails ") %> +<%= render :template => don_get_theme("shared/category_title_list"), :locals => {:category => "donrails"}
どうもrails2.1には対応していないのでざっくり削除.
というわけでなんとかなったのでrails2.2対応が次かな.
railsが1.2でUbuntuが7.10だった時代に作っていたdb2をつかったアプリをいい加減rails2.2に対応させたので忘れる前にメモ.
旧 | 新 | |
Ubuntu | 7.10 | 8.04 |
rails | 1.2.6 | 2.2.2 |
DB2 | 9.5 | 9.5(同じ) |
gem | 0.84(rubygems.debのやつ) | 1.3.1 |
ibm_db | 0.94 | 1.0.0 |
そしてActiveScaffoldも使っている.
sudo gem update --system sudo apt-get remove rubygems
sudo -s . /home/db2inst1/sqllib/db2profile export IBM_DB_DIR=/home/db2inst1/sqllib export IBM_DB_LIB=/home/db2inst1/sqllib/lib32 gem install ibm_db gem install rails -y gem install rake -y
rails2.2では1.2時代に動いてたactive_scaffoldはもう動かない.http://activescaffold.com/ をみるとやりかたが書いてある.
git clone git://github.com/activescaffold/active_scaffold.git vendor/plugins/active_scaffold && rm -rf vendor/plugins/active_scaffold/.git
config/environment.rbに config.action_controller.sessionを追加.
config.action_controller.session = { :session_key => "hogecode", :secret => "
abcdefghijklmnopqrstuvwxyz…." }
rake db:migrateかますと,config/environments/development.rbがおかしいことを
指摘してくれる
$ rake db:migrate --trace ..... ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `cache_template_extensions=' for ActionView::Base:Class /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in `send'
http://d.hatena.ne.jp/zariganitosh/20080621/1214110380 にある
config/environments/development.rbの「config.action_view.cache_template_extensions= false」オプションは推奨されなくなり、何の影響も与えないらしい…。削除してくださいと警告されているので、削除してしまった。(警告なので削除しなくてもサーバーは起動する。)
というかんじ.
PAGESIZEが小さいとDB2におこられることがある.
== Initial: migrating ======================================================== -- create_table("contacts", {:force=>true}) -> 0.1195s -- create_table("inbounds", {:force=>true}) rake aborted! An error has occurred, this and all later migrations canceled: ActiveRecord::StatementInvalid: [IBM][CLI Driver][DB2/LINUX] SQL0286N A default table space could not be found with a page size of at least "8192" that authorization ID "DB2INST1" is authorized to use.
しょうがないのでdbをつくりなおす.(db2inst1 ユーザでおこなう)
$ db2 drop db xdmsdev $ db2 create database xdmsdev using codeset utf-8 territory us PAGESIZE 32 K
できたら
rake db:migrate
が,rake test:unitsはibm_db 1.0.0では対応してないようだ.
rake aborted! Task not supported by 'ibm_db'
とりあえずこれでokだった.donrailsの場合はCSRFを自前で対応していたり,いろいろ凝ったことをしているので大変だったが,こっちはあんがいとうまくいった.