Redirect not working as I'm expecting in Rails

EastsideDev

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?

Routes:

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

NM Pennypacker

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

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

URL redirect not working with .htaccess not working

분류에서Dev

Django redirect() not working

분류에서Dev

jquery redirect on keydown is not working

분류에서Dev

Codeigniter: Redirect not working

분류에서Dev

Render and redirect_to in rails

분류에서Dev

Rails redirect_to not rendering

분류에서Dev

Primefaces comondButton redirect stopped working

분류에서Dev

Rails redirect_to choice page

분류에서Dev

Rails redirect_to with DELETE method

분류에서Dev

Angular Select List Binding an Object when I was expecting a Value

분류에서Dev

Redirect 301 on changed root name not working

분류에서Dev

wp_logout_url($redirect); is not working

분류에서Dev

Solr not working Rails

분류에서Dev

ruby on rails, redirect if hitting back button in browser

분류에서Dev

Rails - redirect to show page passing a parameter

분류에서Dev

I'm Working with a button command, but can't see what's wrong with this code using elseif statements

분류에서Dev

I'm working with R. I am performing a k-NN analysis on the training data, but I keep getting an error on my knn function. How can I fix this

분류에서Dev

Angulars + Rails: ngInclude directive not working

분류에서Dev

Nginx redirect - what am I doing wrong?

분류에서Dev

In Laravel " return Redirect::back()->withErrors($Validator)->withInput(); " Not Working For me?

분류에서Dev

ZF2 redirect() not working while header location does

분류에서Dev

Redirect from the domain with www to the root domain - working but not completely properly

분류에서Dev

Redirect to action based on role not working. Maybe routing needed?

분류에서Dev

I'm trying to get jquery working in the background.js of my chrome extension and it won't work. why?

분류에서Dev

Rails redirect_to 부모 부분 /보기

분류에서Dev

Rails Redirect / Post to apply # create via jQuery / Ajax

분류에서Dev

Rails 4.1 nested routes redirect_to test won't pass

분류에서Dev

Rails Admin config.authorize_with redirect user if not admin

분류에서Dev

Rails: Erratic secondary post request after redirect_to action

Related 관련 기사

  1. 1

    URL redirect not working with .htaccess not working

  2. 2

    Django redirect() not working

  3. 3

    jquery redirect on keydown is not working

  4. 4

    Codeigniter: Redirect not working

  5. 5

    Render and redirect_to in rails

  6. 6

    Rails redirect_to not rendering

  7. 7

    Primefaces comondButton redirect stopped working

  8. 8

    Rails redirect_to choice page

  9. 9

    Rails redirect_to with DELETE method

  10. 10

    Angular Select List Binding an Object when I was expecting a Value

  11. 11

    Redirect 301 on changed root name not working

  12. 12

    wp_logout_url($redirect); is not working

  13. 13

    Solr not working Rails

  14. 14

    ruby on rails, redirect if hitting back button in browser

  15. 15

    Rails - redirect to show page passing a parameter

  16. 16

    I'm Working with a button command, but can't see what's wrong with this code using elseif statements

  17. 17

    I'm working with R. I am performing a k-NN analysis on the training data, but I keep getting an error on my knn function. How can I fix this

  18. 18

    Angulars + Rails: ngInclude directive not working

  19. 19

    Nginx redirect - what am I doing wrong?

  20. 20

    In Laravel " return Redirect::back()->withErrors($Validator)->withInput(); " Not Working For me?

  21. 21

    ZF2 redirect() not working while header location does

  22. 22

    Redirect from the domain with www to the root domain - working but not completely properly

  23. 23

    Redirect to action based on role not working. Maybe routing needed?

  24. 24

    I'm trying to get jquery working in the background.js of my chrome extension and it won't work. why?

  25. 25

    Rails redirect_to 부모 부분 /보기

  26. 26

    Rails Redirect / Post to apply # create via jQuery / Ajax

  27. 27

    Rails 4.1 nested routes redirect_to test won't pass

  28. 28

    Rails Admin config.authorize_with redirect user if not admin

  29. 29

    Rails: Erratic secondary post request after redirect_to action

뜨겁다태그

보관