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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:56:49+00:00 2026-06-03T02:56:49+00:00

Ive been trying to get this to work for 3 days now. I cant

  • 0

Ive been trying to get this to work for 3 days now. I cant seem to understand why it doesn work. When the user clicks that link_to tag on the view it should execute the csv function in the controller. Instread I get an exception.


Here are the relevant files

Controller file: (users_controller.rb)

def csv 

end

(Routes.rb):

resources :users 

View: (show.html.erb)

 <%= link_to 'Click HERE to open file', @user.image.url  %><br/><br/><br/>
 <%= label_tag(:q, "Parse CSV File:") %><br/>
 <%= link_to 'CSV', csv_user_path %>
 <% end %>

When I click on the “link_to ‘CSV’.. tag above. It gives me this exception:

 NameError in Users#show 
 Showing /Users/AM/Documents/RailsWS/bmc_mam/app/views/users/show.html.erb where line #47 raised:
Extracted source (around line #47):

44:         
45:  <%= label_tag(:q, "Parse CSV File:") %><br/>
46:  
47: <%= link_to 'CSV', csv_user_path %>
48:             
49:         
50:         

The browser URL is as follows when the exception occurs:

http://localhost:3000/users/28

Its clearly getting to the function but the URL mapping /routing is clearly messed up. I m wondering how to fix it…..Ive tried several approaches over the past few days, none seem to be working.
This is the closest Ive gotten to making it work as in …

Thanks in advance for your help.


After post answer posted below by @Gavin Miller:

I cahnged my routes.rb file to this:

get 'csv' => 'users#csv'
resources :users 

Now Im getting this exception:

NameError in Users#show

Showing /Users/AM/Documents/RailsWS/bmc_mam/app/views/users/show.html.erb where line #47    raised:

undefined local variable or method `csv_user_path' for #<#  <Class:0x00000104e7f6f8>:0x00000103a23c68>

Extracted source (around line #47):

44:         
45:             <%= label_tag(:q, "Parse CSV File:") %><br/>
46:             
47:             <%= link_to 'CSV', csv_user_path %>
48:             
49:         
50:         
  • 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-03T02:56:50+00:00Added an answer on June 3, 2026 at 2:56 am

    Just declaring resources :users is only going to infer the 7 standard RESTful actions1. if you want csv to be accepted as a route, you’ll have to explicitly define it:

    get 'csv' => 'controller#action'
    

    where controller == users and action == csv.


    Re-addressing the edited question… You’ll need to pass a user object to the csv_user_path function:

    <%= link_to 'CSV', csv_user_path(@user) %>
    

    It also appears like you’d like the url to be associated with the user, so you can declare it as a member to get a url like: http://localhost:3000/users/28/csv for that result you can use this code:

    resources :users do
      member do
        get 'csv'
      end
    end
    

    1 RESTful actions are index, new, create, show, edit, update, destroy as seen in Rails Routing Guide

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

Sidebar

Related Questions

I have been trying to get this to work for about three solid days
I've been trying for the last two days to get this to work with
I've been spending a few days (or more) trying to get this to work.
I've been trying to get this to work for days upon days and it
I've been trying to get this to work for the last two days but
I've been trying to get this module to work and no matter what I've
I've been struggling a bit trying to get this to work. Getting clojure 1.3
2 days I've been trying to get my head around this, but no joy.
I've been trying to figure this out and can't seem to get it. Here
I've been trying to get this complex MYSQL query to work exactly right over

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.