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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:16:33+00:00 2026-06-10T23:16:33+00:00

Route resources :cars do collection do get :f01a end end Controller class CarsController <

  • 0

Route

resources :cars do
  collection do
    get :f01a
  end
end 

Controller

class CarsController < ApplicationController
  def f01a
    @user = User.find(params[:id])
    @count = Count.find_by_user_id(@user)
    @count.increment!(:f02)
    redirect_to @user
  end
end

View

<%= button_to "add f01", f01a_cars_path %>

I can’t get this to work. I need to execute this code from a button.

  • 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-10T23:16:34+00:00Added an answer on June 10, 2026 at 11:16 pm

    button_to sends a POST request, but your routing is setup to only accept GET requests. You should change it to:

    resources :cars do
      collection do
        post :f01a
      end
    end
    

    Since you’re using params[:id] in your action, but not sending it in at all, you’ll need to pass it in your button_to:

    <%= button_to "add f01", f01a_cars_path(:id => something)
    

    (Replace something with whatever ID you want to pass.)

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

Sidebar

Related Questions

in routes.rb resources :restaurants do collection do get 'nearby' end resources :tickets end resources
Given a simple namespaced route map.namespace :api do |api| api.resources :genres end how can
My route looks like the following: map.namespace(:admin) do |admin| admin.resources :pages end and my
I've added a resource route to my app using - resources :cars I've used
For this route: resources :projects do member do resources :stakeholders end end The generated
I have the following route: resources :widgets do resources :orders end so that a
I have a nested route like so: resources :apps do resources :issues end the
I have a route: resources.router.routes.page.route = page/:page resources.router.routes.page.defaults.module = core resources.router.routes.page.defaults.controller = page resources.router.routes.page.defaults.action
I have a nested route: resources :period_registrations do member do post :save_period end that
I have a nested route as: resources :wsps do member do get :location get

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.