<%= button_to("Randomize someting to do!", {:action => "random_task"}) %>
このメソッドが呼び出すボタンを使用して呼び出す必要があるランダム選択ジェネレーターを作成したいrandom task
def random_task
x = rand(Task.first.id..Task.last.id)
@task = Task.find(x)
rescue ActiveRecord::RecordNotFound => e
random_task
respond_to do |format|
format.html { render @task}
format.json { head :no_content }
end
end
これは私のview/random_task.html.erbをコールバックすることになっています
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name,:disabled=>true %>
</div>
<div class="field">
<%= f.label :category %><br />
<%= f.text_field, :category,:disabled=>true %>
</div>/tasks/
<div class="field">
<%= f.label :points %><br />
<%= f.number_field :points,:disabled=>true %>
</div>
<div class="rank_buttons">
<%= link_to 'Vote up', :action => 'rate_up', :id => task.id %>
<%= link_to 'Vote down', :action => 'rate_down', :id => task.id %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
編集Q: 適切に記述されている場合、レンダリング フォームを正しい方法で呼び出すにはどうすればよいですか?