Reputation: 6639
Environment:
Rails: 3.2.12
Ruby: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
In my routes.rb, I have:
match '/attendance', to: "attendance#attendance_dashboard"
match '/check_in', to: "attendance#check_in"
In my attendance_controller.rb, I have:
def attendance_dashboard
@registered_and_not_checked_in = get_registered_and_not_checked_in()
end
def check_in
logger.info("Email: #{params["party"]["email"]}")
redirect_to attendance_url
end
When I do to myapp/attendance, it behaves like it should and displays a table with the last field in every row being a link to the attendance controller's check_in action and the params include the hash Party.
When I click on the link, I 404. Specifically, here's what the test.log says (the logger info is to make sure I am not bombing up until the redirect):
Processing by AttendanceController#check_in as HTML
Parameters: {"party"=>{"email"=>"[email protected]", "event_id"=>"3", "first"=>"Rrr", "last"=>"Rrrrr", "payment"=>"0.0", "transaction_id"=>""}}
[1m[35mBlogPost Load (0.4ms)[0m SELECT `blog_posts`.* FROM `blog_posts`
[1m[36mUser Load (0.4ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1[0m
Email: [email protected]
Completed 404 Not Found in 5ms
I also tried the following redirect syntax:
redirect_to attendance_path
What am I missing?
This is the output of rake route:
/attendance(.:format) attendance#attendance_dashboard
check_in /check_in(.:format) attendance#check_in
Note that unlike check_in, there is no "path" even though the syntax in routes.rb is the same
Upvotes: 1
Views: 39
Reputation: 6942
You should have this in your routes file:
match '/attendance', to: "attendance#attendance_dashboard", :as => :attendance
match '/check_in', to: "attendance#check_in", :as => :check_in
Upvotes: 3