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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:33:11+00:00 2026-05-15T08:33:11+00:00

I created the following route: map.todo todo/today, :controller => todo, :action => show_date Originally,

  • 0

I created the following route:

  map.todo "todo/today",
            :controller => "todo",
            :action => "show_date"

Originally, the ‘show_date’ action and associated view would display all the activities associated for that day for all the Campaigns.

This ended up being very slow on the database…it would generate roughly 30 records but was still slow.

So, I’m thinking of creating a partial that would first list the campaigns separately.

If someone clicked on a link associated with campaign_id = 1, I want it to go to the following route:

todo/today/campaign/1

Then I would like to know how to know that the ‘1’ is the campaign_id in the controller and then just do its thing.

The reason I want a distinct URL is so that I can cache this list. I have to keep going back to this and it’s slow.

NOTE: It’s possibly the problem actually is that I’ve written the queries in a slow way and sqlite isn’t representative of how it will be in production, in which case this work-around is unnecessary, but right now, I need a way to get back to the whole list quickly.

  • 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-15T08:33:11+00:00Added an answer on May 15, 2026 at 8:33 am

    The code above by @Damien is correct but incomplete. It should be:

    map.todo "todo/today/campaign/:id", :controller => "todo", :action => "show_date"
    

    in your views all you have to do is:

    <%= link_to "Campaign 1", todo_path(:id => 1) %>

    or simply

    <%= link_to "Campaign 1", todo_path(1) %>

    and the particular campaign id can be fetched using params[:id] in your action.

    And yeah, sqlite is not production ready.

    EDIT: The latter part is quite easy to implement:

    However, you have to change the route slightly,
    The route will now become,

    map.todo "todo/today/:campaign/:id", :controller => "todo", :action => "show_date"
    

    in your views:

    <%= link_to "Campaign 1", todo_path(:campaign => "campaign", :id => 1) %>
    

    In your todo controller, show_date action:

    def show_date
    
    #IF YOU ARE USING THIS REPEATEDLY IN LOTS OF DIFFERENT ACTIONS THEN A BETTER PLACE FOR THIS WOULD BE AS A HELPER IN application_controller.rb
    
     if params[:id].nil? && params[:campaign].nil?
        #DO SOMETHING WHEN BOTH ARE NIL,
     elsif params[:campaign]!="campaign"
        #DO SOMETHING WITH CAMPAIGN BEING SOMETHING OTHER THAN "CAMPAIGN"
     elsif params[:campain]=="campaign" && params[:id].nil?
        #DO SOMETHING WITH ID BEING NIL.
     else
        #FIND YOUR CAMPAIGN HERE.
     end
    end
    

    Hope this helps. 🙂

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

Sidebar

Related Questions

I have a route that looks like the following: map.newsletter '/newsletter', :controller => newsletter
I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array
My route looks like the following: map.namespace(:admin) do |admin| admin.resources :pages end and my
I created the following route: routes.MapRoute( TestRoute4, // Route name Report {ref_id} Test Board,
I created the following route: routes.MapRoute( Notes 1, // Route name {book}-{id}, // URL
I add this line in my routes.rb file map.connect ':controller/:action/:id/:title', :controller => recipes thinking
I have created following rule in the .htaccess file located at the root of
I have created following thing in android using android compatibility support package Basically i
I created the following code to calculate the duration between two timestamps which can
I created the following method for retrieving stored settings from the database: public String

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.