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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:06:17+00:00 2026-06-07T15:06:17+00:00

Im trying to see why this custom route for this method throws an exception:

  • 0

Im trying to see why this custom route for this method throws an exception:

tasks_controller.rb
    def run
        @task = Task.find(params[:id])
        @task.run_task
        flash[:notice] = "Running Task #{@task.task_name}in the background, please click     show to see results after a few seconds"
    redirect_to tasks_url
    end

Task model
task.rb

  def run_task
    if task.task_name == "game_state_count"
        task.description =  "Running task game_state_count"
    elsif task.task_name == "file_reader"
        task.description"Running task file_reader"
    elsif task.task_name == "copy_dupes_from_listings"
        task.description "Running task copy_dupes_from_listings"
    elsif task.task_name == "remove_dupes_from_listings"
        task.description "Running task remove_dupes_from_listings"
    end
  end

routes.rb

     #For Admin Tasks run method
     match "tasks/run/(params[:id])" => "tasks#run", :as => :run_tasks_path

tasks/index.html.erb

<h1>Tasks</h1>

    <table>
      <tr>
       <th>Name</th>
       <th>Description</th>
       <th>Run</th>
        <th>Status</th>
        <th>Start Time</th>
      </tr>

    <% @tasks.each do |task| %>
      <tr>
       <td><%=task.name %></td>
       <td><%=task.description %></td>
       <td><%= link_to 'Run', run_tasks_path  %></td>
       <td><%=task.Status %></td>
       <td><%=task.start_time %></td>
       <td><%= link_to 'Show', task %></td>

     </tr>
    <% end %>
    </table>

    <br />

 <%= link_to 'New Task', new_task_path %>

Exception

NameError in Tasks#index

Showing /Users/AM/Documents/RailsWS/appXXX/app/views/tasks/index.html.erb where line #16 raised:

undefined local variable or method `run_tasks_path' for #<# <Class:0x000001028b9ce8>:0x000001028b4450>

Extracted source (around line #16):

13:   <tr>
14:     <td><%=task.name %></td>
15:     <td><%=task.description %></td>
16:     <td><%= link_to 'Run', run_tasks_path  %></td>
17:     <td><%=task.Status %></td>
18:     <td><%=task.start_time %></td>
19:     <td><%= link_to 'Show', task %></td
  • 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-07T15:06:19+00:00Added an answer on June 7, 2026 at 3:06 pm

    Rewrite route like this

    match "tasks/run/:id" => "tasks#run", :as => :run_tasks
    

    upd: And change

    <td><%= link_to 'Run', run_tasks_path  %></td>
    

    to

    <td><%= link_to 'Run', run_tasks_path(taks)  %></td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm kinda stuck trying to see why, when I use this custom UIView to
I am trying to use this method to draw a string into a custom
See this question. How to show popup message like in stackoverflow I am trying
I'm really stuck trying to use java wrapper library for opencv's cvMatchTemplate. See this
I'm looking around trying to see if anybody has asked this before. I don't
As you can see in this jsfiddle , I'm trying to make a toggle
I am trying to get this to work but can't see where I'm going
Im trying to use this page slider jquery plugin, you can see the demo
I have the following and you can see I am trying to pass this
I'm trying to create a a custom post method but i'm having trouble finding

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.