I've been digging through routing documentation and seem to have only uncovered half of the necessary info needed for this one.
If I create a route which looks like:
I'm afraid I'm completely unclear on how to create an appropriate
link_to incantation which is capable of fulfilling the above.
For example, I seem to have no problems creating this URL:
but I've yet to find appropriate docs which explains how to create this:
Could someone provide a helpful example and/or a link to docs which discusses how to do this?
I realize that trying to use
link_to might be completely inappropriate here. And I realize I could munge together some code which will craft the appropriate links, but I suspect that doing so will completely miss some better, Ruby-on-Rails way to doing this.
Edit: Corrected proposed
match route, above.
Edit 2: Going on "mu is too short"'s suggestion, here's what my routes.rb now looks like:
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
and here's the relevant view:
<% 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>
and here's what I get back after the initial reload (before trying to restart 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
I'll pastebin what I got back after my failed attempt to restart WEBrick, if interested.