Hi i have a bit of a problem as to the index doesnt seem to show properly in my rake routes
I have defined the index in my controller module like so
def index
@user_friendship = current_user.user_friendships.all
end
and i also defined it in the view as index.html.erb
but my problem is that it is now showing in my rake routes this is what i only get
accept_user_friendships PUT /user_friendships/accept(.:format) user_friendships#accept
user_friendships POST /user_friendships(.:format) user_friendships#create
new_user_friendships GET /user_friendships/new(.:format) user_friendships#new
edit_user_friendships GET /user_friendships/edit(.:format) user_friendships#edit
GET /user_friendships(.:format) user_friendships#show
PATCH /user_friendships(.:format) user_friendships#update
PUT /user_friendships(.:format) user_friendships#update
DELETE /user_friendships(.:format) user_friendships#destroy
as you can see it isnt showing in my rake routes
here is the code i have for the routes.rb
resource :user_friendships do
member do
put :accept
end
end
if you guys can help me with this one it would be great also pls note that i am a bit of a beginner in rails and just followed a tutorial that my friend gave me so i am having trouble in fixing the errors that came with the tutorial that seems a bit old, and thanks again!
By default resource not create a index action. You should use resources:
resources :user_friendships do
member do
put :accept
end
end
Differences between resource and resources
Try using resources instead of resource. resource does not create an index action by default instead you could explicitly say it to ie. resource only: [:index, :show, :edit]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With