gkr
gkr

Reputation: 79

Submitting a Form from index page in Rails

I'm Rails newbie.

How to make a form which allows user to choose a language(en,fr etc) through Radio buttons in Home#Index View to Submit to Home#Language action ?

Thanks in advance

Upvotes: 1

Views: 2135

Answers (1)

Alex
Alex

Reputation: 9471

<%= form_tag language_path, :method => :post do %>
  <%= label_tag :language_english, 'English' %>
  <%= radio_button_tag :language, 'english' %>
  <%= label_tag :language_french, 'French' %>
  <%= radio_button_tag :language, 'french' %>
  <%= submit_tag %>
<% end %>

Where language_path is the path defined in your routes.rb, such as

match "/home/language" => "home#language", :as => 'language'

Upvotes: 3

Related Questions