Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6178053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:24:01+00:00 2026-05-24T00:24:01+00:00

I am new to Rails and now trying to write a small project in

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:24:02+00:00Added an answer on May 24, 2026 at 12:24 am

    First of all routes.rb are file to map url to a function on controller

    the basic example of routing is like here

    Foo::Application.routes.draw do
      get '/form'  => 'project#form'
      get '/submit'  => 'project#submit'
      get '/logedin'  => 'project#logedin'
    end
    

    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

    class ProjectController < ApplicationController
    def form
        #will render view/project/form.html.erb
    end
    
    def submit
        if params[:password] == 'secret'
            redirect_to '/logedin'
        else
            #you can redirect to form again 
            #or render the form again
            render 'form' #render the view/project/form.html.erb
        end
    end
    
    def logedin
        render :text  => 'you are loged in'
    end
    

    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/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I installed the Rails installer. Now I'm trying to create a new Rails project.
Starting a new rails project and we have a well-thought-out color palette, and want
I'm sure this is basic as I'm a new Rails user and want to
I'm trying to write a catch-all route in Rails 3, but I want to
I'm new to Ruby on Rails, I know things but now I have to
I know new rails apps come with an empty favicon.ico file. I want to
I am using Railside to create a new Rails project. I am on a
I am creating a new rails app as a learning project. I have already
I'm currently trying to set up integration/acceptance testing for a new rails 3 application
So I'm working on a new rails project which involves running multiple website from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.