I am new to Rails and now trying to write a small project in Rails. As part of this project I want to process a form Data(Password). My form is
<form name="input" action="http://0.0.0.0:3000/submit/" method="get">
Password: <input type="text" name="password" />
<input type="submit" value="Login" />
If the entered password is correct I want to display another html page, the original password is not stored in Database, means just want to compare against a character string. I created a controller and view by using ‘rails generate controller project’. I think the code for password match should be written in the file ‘project_controller.rb’ in ‘app/controllers’ directory. But how to write code for password match and how to map the url in ‘routes.rb’ file ? If ‘get’ method changed to ‘post’ what are the necessary changes required ?
First of all routes.rb are file to map url to a function on controller
the basic example of routing is like here
there I have 3 function in my project_controller.rb which map to a function
you can change it to post by changing the ‘get’ to ‘post’
here is the example code of the project_controller.rb
end
form function will just render the default view which is in app/view/project/form.html.erb
submit is the main logic. you can access the form data using variabel caled params
the code is straight forward. you can learn the details on rails guide http://guides.rubyonrails.org/