开发者

I18n.t instead of hard value results in a different url

开发者 https://www.devze.com 2023-04-11 11:50 出处:网络
I have a link like this: <%= link_to \"Logout\", destroy_user_session开发者_运维技巧_path, :method => :delete %>

I have a link like this:

<%= link_to "Logout", destroy_user_session开发者_运维技巧_path, :method => :delete %>

This results in a link with the url "/users/sign_out". When I replace this with i18n like this:

<%= link_to I18n.t :logout_link, destroy_user_session_path, :method => :delete %>

It results in a link with the right text, but the url is "site/index", which is my root_path. Why is this going wrong? Thanks!


please try this:

<%= link_to I18n.t(:logout_link), destroy_user_session_path, :method => :delete %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号