1

How can I set different http status but keep normal view? Currently I have these two lines in my action

self.status = 403
self.body = Web::Views::Login::Form.render(exposures)

However my problems is that I get complete different page, just gray page with big rectangle in the middle with with HTML text of self.body (escaped, so I see the actual source code, not the page).

So, how can I set reponse code while keeping regular view processing (== displaying self.body)?

graywolf
  • 7,092
  • 7
  • 53
  • 77
  • What browser are you seeing this in? Some browsers will render alternate content depending on the response. Hanami will likewise render its own views for non-success codes - https://github.com/hanami/hanami/blob/master/lib/hanami/views/default.rb#L10 – Joe Dec 20 '17 at 01:08
  • @Joe so failed login should return 200? :-O that sounds... weird. The action (login attempt) obviously failed, so getting back 200 doesn't seem correct; anyway regardless of it being good idea or not, I'm still having hard time believing it's just not possible to do :/ – graywolf Dec 20 '17 at 09:54
  • Duh. I was reading question wrong. – Joe Dec 20 '17 at 11:34

1 Answers1

1

Not possible to do at the moment, see https://github.com/hanami/hanami/issues/874 for workaround.

graywolf
  • 7,092
  • 7
  • 53
  • 77