It could be very useful if I can make controllers return information customized to a user if he/she is logged in, otherwise return default information.
Right now I must rescue the error by doing something like this:
begin
user = authenticate_user!
info = user.some_specific_info
rescue => error
info = generic_info
ensure
present info
end
I'd love to have a helper that doesn't fail (nor throw 400 error), so the following code will be equivalent:
user = authenticate_user # there is no "!"
if user
info = user.some_specific_info
else
info = generic_info
end
present info
It could be very useful if I can make controllers return information customized to a user if he/she is logged in, otherwise return default information.
Right now I must rescue the error by doing something like this:
I'd love to have a helper that doesn't fail (nor throw 400 error), so the following code will be equivalent:
Thank you in advance.