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 8271415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:50:05+00:00 2026-06-08T06:50:05+00:00

I am working through Agile Web Development with Rails 4th Edition (Rails 3.2+) and

  • 0

I am working through Agile Web Development with Rails 4th Edition (Rails 3.2+) and I am somewhat confused by the button_to method. The book as well as every other google search I have done says the button_to uses a POST request. However, when I inspect the page, the button_to appears to be using a GET method.

Now, I could have this wrong, but I come from a php background and a POST method always meant that the data was being passed to the server without the url and accessed through an array server side:

$_POST['form_item'] 

Furthermore, a GET request meant passing data through the url:

someurl.com/somepage?DATA=data_value

Using this button_to code:

  <%= button_to 'Add to Cart', line_items_path(product_id: product_id) %>

This becomes the form output:

<form action="/line_items?product_id=4" class="button_to" method="post">
<div>
<input type="submit" value="Add to Cart" />
<input name="authenticity_token" type="hidden" value="vGT1scGqasbQAMxYwofXHCM62MfSyM/pNty69Ep5t38=" />
</div>
</form>

the action on this form appears to be passing data through the url (?product_id=4). Although I can clearly see the “method=’post'”, isnt this a using GET?

  • 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-06-08T06:50:06+00:00Added an answer on June 8, 2026 at 6:50 am

    As FancyDancy says, it’s still a post request even though the information gets passed through the URL. Rails doesn’t make a distinction between $_GET and $_POST. It only has the equivalent of $_REQUEST: params. So it doesn’t really matter if the product_id gets passed via the URL or via a hidden form field. In both cases you can get it via params[:product_id].

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

Sidebar

Related Questions

I am working through agile web development with rails 4th edition (rails 3.2+) and
Just working through the Agile Web Development with Rails book and near the closing
I am working through the Agile Web Development with Rails book but I have
I'm working through Agile Web Dev w/ Rails book (4th ed) and I'm totally
I'm working through Agile Web Development with Rails, Edition 4 with some tweaks (mostly
Working through Agile Web Development with Rails edition 4 and hit the section on
I'm working through Agile Web Development with Rails and having a problem with Task
I'm working my way through Agile Web Development with Rails and am running into
I am working through the Ruby on Rails 3 tutorial book and typed the
So right now I'm learning Ruby on Rails, and I'm working through the book

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.