update documentation for how to use this in a controller
ccmcbeck opened this issue · comments
Chris Beck commented
Terrific gem.
It can be done on a one-off basis in Rails 3+ using view_context.it(key,...)
But the preferred method is probably this:
class ApplicationController < ActionController::Base
include It::Helper
Very useful for controller flash
messages like this:
if @invitation.accepted?
flash[:notice] = it('flash.invitation_accepted_already', link: new_password_reset_path)
with en.yml
like this:
flash:
invitation_accepted_already:
This invitation has already been accepted.
Sign up as a new user or %{link:reset password} if an existing user.
Chris Beck commented
I also find it very useful to include It:Helper
in rspec/support/utilities.rb
Johannes Barre commented
Thanks for your comment. I will improve the README. However, it's not necessary to include the helper into the controller. Instead, just use It.it()
.