s21gブログをRails-2.2.
1 /opt/local/lib/ruby/ gems/1.8/g ems/erubis -2.6.2/lib /erubis/en hancer.rb: 666:in `gsub!': can't modify frozen string (TypeError)
erubisのソースを見てみると、
lib/erubis
1 def _add_text_to_str(str, text) 2 return if !text || text.empty? 3 text.gsub!(/['\#\\]/, '\\\\\&') 4 str << text 5 end
となっていたので、これをひとまず以下のように直してみました(呼び出しもとをざっと見た感じだと、textを破壊的に変更しなくしても挙動に影響は無さそうだった)。
1 def _add_text_to_str(str, text) 2 return if !text || text.empty? 3 text = text.gsub(/['\#\\]/, '\\\\\&') 4 str << text 5 end
これで先ほどのエラーは出なくなったのですが、 今度は別なエラーが。
1 ActionView::Template Error: You have a nil object when you didn't expect it! 2 You might have expected an instance of Array. 3 The error occurred while evaluating nil.<< 4 On line #13 of app/views/ users/edit .html.erb 5 6 10: <div id="user-param eters"> 7 11: <h2>Account</h2> 8 12: <% 9 13: form_for(:user, @user, 10 14: :url => user_path(@user), :html => {:method => :put}) do |f| 11 15: %> 12 16: <%= hidden_fie ld_tag :from, :edit %> 13 14 /opt/local /lib/ruby/ gems/1.8/g ems/action pack-2.2.2 /lib/actio n_view/hel pers/text_ helper.rb: 42:in `concat' 15 /opt/local /lib/ruby/ gems/1.8/g ems/action pack-2.2.2 /lib/actio n_view/hel pers/form_ helper.rb: 252:in `form_for'
form_forの中のconcatでエラーが出ている模様。こちらもソースを見てみると、
actionpack
1 def concat(string, unused_binding = nil) 2 if unused_bin ding 3 ActiveSupp ort::Deprecatio n.warn("The binding argument of #concat is no 4 longer needed. Please remove it from your views and helpers.", caller) 5 end 6 output_buf fer << string 7 end
output_buf
Railsでerubisを使っている方、情報求む!
See Also
posted by
genki
on Thu 25 Dec 2008
at 17:52