Skip to Content
Agile Web Development with Rails 6
book

Agile Web Development with Rails 6

by Sam Ruby, David B. Copeland, Dave Thomas
February 2020
Intermediate to advanced
496 pages
12h 36m
English
Pragmatic Bookshelf
Content preview from Agile Web Development with Rails 6

Iteration K4: Adding a Locale Switcher

We’ve completed the task, but we need to advertise its availability more. We spy some unused area in the top-right side of the layout, so we add a form immediately before the image_tag:

  <header class=​"main"​>
» <aside>
»<%=​ form_tag store_index_path, ​class: ​​'locale'​ ​do​ ​%>
»<%=​ select_tag ​'set_locale'​,
» options_for_select(LANGUAGES, I18n.​locale​.​to_s​),
»onchange: ​​'this.form.submit()'​ ​%>
»<%=​ submit_tag ​'submit'​, ​id: ​​"submit_locale_change"​ ​%>
»<%​ ​end​ ​%>
» </aside>
 <%=​ image_tag ​'logo.svg'​, ​alt: ​​'The Pragmatic Bookshelf'​ ​%>
  <h1>​<%=​ @page_title ​%>​</h1>
  </header>

The form_tag specifies the path ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Agile Web Development with Rails 5.1

Agile Web Development with Rails 5.1

Sam Ruby, David B. Copeland, Dave Thomas

Publisher Resources

ISBN: 9781680507522Errata Page