For my rails application the associations are as follows:
- A user has many bookmarks and belongs to user.
- A user has many friendships.
- A user has many reminders.
- A user has many comments.
- A bookmark has many comments.
- A comment belongs to a user and belongs to a bookmark.
- A friendship belongs to a user.
- A reminder belongs to a user
My routes.rb file:
Rails.application.routes.draw do
root 'welcome#index'
get 'home', :to => 'home#index'
get 'searchApis', :to => 'home#searchApis'
devise_for :users, :controllers => { registrations: 'registrations' }
resources :users, shallow: true do
resources :bookmarks, except: :new
resources :friendships, only: [:index, :show, :destroy]
resources :reminders
end
resources :bookmarks, shallow: true do
resources :comments
end
end
Am I writing these routes out correctly?
When I rake routes
, I'm getting bookmarks#index
twice so I am confused. The prefix for one of them is bookmark
, and the other is bookmarks
. Why is this happening?
From my understanding, the application does not need to see all of the bookmarks in an index because they are only visible to the user who made them. However, I want reminders to be visible to the user's friends.
I'm hoping to get suggestions to clean up my routes, if possible. I really doubt I am doing this correctly.