私はルーティングのドキュメントを掘り下げてきましたが、これに必要な情報の半分しか明らかにしていないようです.
次のようなルートを作成すると:
match 'attendances/new/:class_date/:student_id'
link_to残念ながら、上記を満たすことができる適切な呪文を作成する方法について、私は完全に不明です.
たとえば、次の URL の作成に問題はないようです。
http://localhost:3000/attendances/new?class_date=2012-05-07&student_id=5
しかし、これを作成する方法を説明する適切なドキュメントをまだ見つけていません:
http://localhost:3000/attendances/new/2012-05-07/5
誰かが役立つ例や、これを行う方法について説明しているドキュメントへのリンクを提供できますか?
ここで使用しようとすることlink_toは完全に不適切である可能性があることを理解しています. そして、適切なリンクを作成するコードをいくつかまとめることができることはわかっていますが、そうすると、これを行うためのより優れた Ruby-on-Rails の方法が完全に失われるのではないかと思います。
編集:match上記の提案されたルートを修正しました。
編集 2:「mu が短すぎる」の提案に進みます。これが私の routes.rb の外観です。
NTA::Application.routes.draw do
  resources :students
  resources :libraries
  resources :year_end_reviews
  resources :notes
  resources :ranktests
  resources :attendances
  match 'attendances/new/:class_date/:student_id', :as => :add_attendance
  resources :ranks
  get "home/index"
  root :to => "home#index"
end
関連するビューは次のとおりです。
<% today = Date.today %>
<% first_of_month = today.beginning_of_month %>
<% last_of_month = today.end_of_month %>
<% date_a = first_of_month.step(last_of_month, 1).to_a %>
<h2><%= today.strftime("%B %Y") %></h2>
<table id="fixedcolDT">
<thead>
  <tr>
    <th>Name</th>
    <% date_a.each do |d| %>
      <th><%= d.day %></th>
    <% end %>
  </tr>
</thead>
<tbody>
<% @students.each do |s| %>
  <tr>
    <td><%= s.revfullname %></td>
    <% date_a.each do |d| %>
      <% student_attend_date = Attendance.find_by_student_id_and_class_date(s.id, d) %>
        <% if student_attend_date.nil? %>
          <td><%= link_to "--", add_attendance_path(d, s.id) %></td>
        <% else %>
          <td><%= student_attend_date.class_hours %></td>
        <% end %>
    <% end %>
  </tr>
<% end %>
</tbody>
</table>
そして、最初のリロード後(WEBrickを再起動する前)に返されるものは次のとおりです。
ArgumentError
missing :controller
Rails.root: /Users/jim/Documents/rails/NTA.new
Application Trace | Framework Trace | Full Trace
config/routes.rb:15:in `block in <top (required)>'
config/routes.rb:1:in `<top (required)>'
This error occurred while loading the following files:
   /Users/jim/Documents/rails/NTA.new/config/routes.rb
興味があれば、WEBrick の再起動に失敗した後に返されたものを貼り付けます。