Hello Rails Application in Ruby on rails - Getting values from text boxes and radio buttons in a simple form and saving them to mysql database.
Model
user.rb
class User ActiveRecord::Base
end
Controller
hello_controller.rb
class HelloController ApplicationController
def respond
@user=User.new(params[:user])
@user.save
end
end
Views
index.html.erb
% form_tag :action=>"respond" do%>
Enter name %=text_field :user, :name%>
Enter Age
%=text_field :user, :age%>
Select the Color
%=radio_button :user, :color, :Blue%> Blue
%=radio_button :user, :color, :Green%>Green
%=submit_tag "submit"%>
%end%>
respond.html.rb
My name is %[email protected]%>
My age is %[email protected]%>
Your selected colour is %[email protected]%>
See the below video to know how to work: