Nicolas Raoul
Nicolas Raoul

Reputation: 60203

How to localize link text in Rails 3?

In my Rails3 app I have:

<%= link_to "Sign out", destroy_user_session_path %>

I know how to localize text, but how to localize link text? I defined "sign_out" in tried:

<%= link_to t( sign_out ), destroy_user_session_path %>

But it generates an error:

undefined local variable or method `sign_out'

What is the correct syntax?

PS: It is even more basic than this question, but I could not find any answer.

Upvotes: 0

Views: 525

Answers (3)

Hck
Hck

Reputation: 9167

<%= link_to t(:sign_out), destroy_user_session_path %>

or

<%= link_to t('sign_out'), destroy_user_session_path %>

You can check other details here.

Upvotes: 1

Miki
Miki

Reputation: 7188

How about link_to t("sign_out"), destroy_user_session_path?

Upvotes: 1

Joel AZEMAR
Joel AZEMAR

Reputation: 2526

<%= link_to t('sign_out'), destroy_user_session_path %>

And you must define the key sign_out: in your local yml file after

Upvotes: 1

Related Questions