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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:43:26+00:00 2026-06-01T08:43:26+00:00

Suppose I have an events controller. If I request /events by GET it will

  • 0

Suppose I have an events controller. If I request /events by GET it will respond with index action in news controller, this view will display future events.

I want to add a new action called past, it is like index, which return an array of Events but with another query.

I have added to routes.rb this chunk:

resources :events do
  collection do
    get :past
  end
end

and I this chuck to events_controller:

def history
  @events => Event.past
  render :template => 'index'
end

But when I request http://127.0.0.1:3000/events/past in browser it does not work, in log are thrown these lines:

Started GET "/events/past" for 127.0.0.1 at 2012-04-02 19:32:01 -0500
  Processing by EventsController#show as HTML
  Parameters: {"id"=>"past"}

And finally here you have rake routes output:

            events GET    /events(.:format)                  {:action=>"index", :controller=>"events"}
             event GET    /events/:id(.:format)              {:action=>"show", :controller=>"events"}
       past_events GET    /events/past(.:format)             {:action=>"past", :controller=>"events"}
  contact_us_event POST   /events/:id/contact_us(.:format)   {:action=>"contact_us", :controller=>"events"}
                   GET    /events(.:format)                  {:action=>"index", :controller=>"events"}
                   POST   /events(.:format)                  {:action=>"create", :controller=>"events"}
         new_event GET    /events/new(.:format)              {:action=>"new", :controller=>"events"}
        edit_event GET    /events/:id/edit(.:format)         {:action=>"edit", :controller=>"events"}
                   GET    /events/:id(.:format)              {:action=>"show", :controller=>"events"}
                   PUT    /events/:id(.:format)              {:action=>"update", :controller=>"events"}
                   DELETE /events/:id(.:format)              {:action=>"destroy", :controller=>"events"}

Other test was check routes using Rails console:

$ script/rails c
1.9.2-p318 :001 > rs = ActionController::Routing::Routes
1.9.2-p318 :002 > rs.recognize_path "/events/past", :method => :get
 => {:action=>"show", :controller=>"events", :id=>"past"} 

What’s wrong?

  • 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-01T08:43:27+00:00Added an answer on June 1, 2026 at 8:43 am

    The problem was on routes precedence, here you have a routes.rb chunk that works:

    resources :events, :only => [:index, :show] do
      get 'past', :on => :collection
      post 'contact_us', :on => :member
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So lets suppose we have an action in a controller that looks a bit
Suppose I have this jQuery code. $(document).delegate('a[title]', 'click', function(event) { var txt = //
Suppose I have two events: Public Sub Control1Updated() Handles control1.TextChanged control2.Text = SomeFunction(control1.Text) End
Suppose i have this ($ = jquery): $.fn.my_function = function() { function foo() {
In my application I have View that observes Model changes. Controller is responsible for
Suppose you have the tables Presentations and Events . When a presentation is saved
Suppose I have a event handler which makes two AJAX calls to the server:
I have a custom event handler, or I suppose some call it a custom
Suppose I have: public class foobar { public int lorem; public int ipsum; }
Suppose we have the following table data: ID parent stage submitted 1 1 1

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.