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%>
<%=text_field :user, :name%>
<%=text_field :user, :age%>
<%=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: