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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:46:20+00:00 2026-06-12T13:46:20+00:00

My model summary: A user has many appointments. An appointment has many bookings. A

  • 0

My model summary: A user has many appointments. An appointment has many bookings. A Booking belongs to an appointment.

I’m trying to link_to a specific view (called “users_bookings”) that lists all the bookings for a specific appointment. Here is what I have tried:

<% current_user.appointments.each do |appointment|%>
    <%= link_to "view all bookings", users_bookings_appointment_booking_path(appointment)%>
<%end%>

This is the error I get:

undefined method `users_bookings_appointment_bookings'

Additional Info:

Routes:

resources :appointments do
    resources :bookings do
      get 'users_bookings', :on => :collection
    end        
  end

Bookings Controller create Action:

def create
    @appointment = Appointment.find(params[:booking][:appointment_id])
    @booking = @appointment.bookings.new(params[:booking])

Bookings controller Users_bookings Action:

def users_bookings
    @appointment = Appointment.find(params[:booking][:appointment_id])
    @bookings = @appointment.bookings.all
end

Users_bookings view:

<% @bookings.each do |booking| %>
    <td><%= booking.appointment_date%></td>
    <td><%= booking.start_time %></td>
    <td><%= booking.end_time %></td>
<%end%>
  • 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-12T13:46:21+00:00Added an answer on June 12, 2026 at 1:46 pm

    You shouldn’t use match (as others have suggested) unless you really want to match all HTTP requests (GET, POST, etc.) for that URL. Instead, just add a route to the resource in the do block:

    resources :appointments do
      resources :bookings do
        get 'user_bookings', :on => :collection
      end
    end
    

    This will add an additional route for a GET request to `/appointments/:appointment_id/bookings/user_bookings’ and route it to ‘bookings#user_bookings’.

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

Sidebar

Related Questions

I have a user model that has many fields (let's say 30 for this
I have a Project model and it has some text attributes, one is summary.
model Sample has attributes car,bike x =bike y = Sample.new How can I do?
#model class Promotion(models.Model): name = models.CharField(max_length=200) start_date = models.DateTimeField() end_date = models.DateTimeField() #view def
model.py: class Tribes(Group): members = models.ManyToManyField(User, related_name='tribes', verbose_name=_('members')) i want to store a number
Model: class Session(models.Model): tutor = models.ForeignKey(User) start_time = models.DateTimeField() end_time = models.DateTimeField() def __unicode__(self):
model: User has_one :beta_invite before_save :beta_code_must_exist def beta_code_must_exist if beta_invite_id == beta_invite.find_by_name(beta_invite.id) user else
Problem Summary When run in batch mode, my user identity is lost but (like
Summary: u = self.instance.user in def save(self, *args, **kwargs): u = self.instance.user u.first_name =
I'm new to MVC. You have been warned... I have User model that can

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.