[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 2chのread.cgiへ]
Update time : 05/09 22:42 / Filesize : 246 KB / Number-of Response : 911
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

Ruby 初心者スレッド Part 24



710 名前:デフォルトの名無しさん mailto:sage [2009/01/23(金) 10:24:50 ]
Rails1.2.6を使って作成しているのですが、selectを動的に変化させようとすると ActionView::TemplateError (undefined method `number_select' for #<HashWithIndifferentAccess:0xb722adf0>
というのが出てしまいます。回避策があればご教授ください。

<やっていること>
index.rhtmlの中を次のようにしています。
<div id="all">
<table>
<tr><td id="first"><%= render :partial => 'first_info' %></td id="first"></tr>
<tr><td id="second"><%= render :partial => 'second_info' %></td id="second"></tr>
<tr><td id="third"><%= render :partial => 'third_info' %></td id="third"></tr>
</table>
</div id="all">

_first_info.rhtmlには次のような selectがあります。
<%= select(:first_info, :number_select, @numbers, {:selected => @select_value}, {:onchange => remote_function(:submit => :first_info, :url => { :action => :change_select }}) %>
@numbersはコントローラー側で @numbers = ActiveSupport::OrderedHash.new してデータベースから値を格納しています。

_second_info.rhtml のテキストボックスに値を入力し、ボタンを押したら、その値をDBに登録し、_first_info.rhtmlの selectのリストに入力値を追加しようと以下のように処理しています。

1.コントローラーの_second_info.rhtmlから次の関数が呼ばれる
def second
データベースへ登録
@numbers = ActiveSupport::OrderedHash.new
@numbers へデータベースの値を格納
@select_value = 1
end

2. second.rjsは _first_info.rhtmlを更新するため、次のようになっている
page[:first_info].replace_html :partial => 'first_info'







[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<246KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef