jeremyevans / rodauth

Ruby's Most Advanced Authentication Framework
http://rodauth.jeremyevans.net
MIT License
1.65k stars 95 forks source link

Looks like `rodauth.change_login_route` ignores `prefix` setting #358

Closed okliv closed 11 months ago

okliv commented 11 months ago

for this setup

plugin :rodauth do
  enable :login, :email_auth, :create_account, :verify_account, :i18n, :change_login, :verify_login_change
  prefix '/cabinet'
  # ...
end

rodauth.change_login_route method in my view

still gives me just /change-login route (instead of /cabinet/change-login)

jeremyevans commented 11 months ago

If you want the prefix, you probably want change_login_path. I think change_login_route actually gives you change-login, not /change-login.

okliv commented 11 months ago

Hmm... Thanks, it works, but change_login_path is not documented here at all.

And it confuses with ..._route methods in general because if i use prefix, i actually can't imagine where i can use ..._route methods (instead of ..._path, if i understood it right). I just want correct prefixed hrefs always everywhere.

jeremyevans commented 11 months ago

change_login_path is not a configuration method, and that page (and similar pages for other features) discuss configuration methods. The *_path methods are documented at the bottom of the table in https://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-rodauth+Methods

The *_route methods are designed to return route names, not paths, and used internally in cases where a route name is used, and where using a path would break things.

okliv commented 11 months ago

I see. Thanks, again. (Now I'm not saying it works wrong. I'm just saying it is not clear. There are multiple places for almost same README and it confuses me every time where i should google it when i have to work with Roda, Rodauth and/or Sequel. It is clear old-school pain from 200x to spend like half an hour to find simple documented feature in multiple varying sources with or even without simple formatting. Sometimes it is easier to debug instead of reading all versions of docs. In this particular case, maybe it would be clearer if *_route methods would be named *_route_name. Just an opinion. Hope you are ok with constructive criticism (or inadequate critics😅))

jeremyevans commented 11 months ago

I understand your frustration, and I agree the documentation could be better. Rodauth's internals are metaprogramming heavy, which is great for avoiding redundancy, but not great in terms of the quality of automatically generated documentation.

While *_route_name is more descriptive, I don't think it's worth changing *_route to *_route_name. The documentation for change_login_route states "The route to the change login action. Defaults to change-login.". Maybe it is not as obvious as it could be, but the lack of a slash does indicate it is only the name and not the path.

If you have specific ideas for improving the documentation (or documentation pull requests), I'm definitely open to them.