Skip to content

Instantly share code, notes, and snippets.

@lrjbrual
Last active April 2, 2016 20:24
Show Gist options
  • Save lrjbrual/a6c2692ffa104e0fdd77550facfba12b to your computer and use it in GitHub Desktop.
Save lrjbrual/a6c2692ffa104e0fdd77550facfba12b to your computer and use it in GitHub Desktop.
<%= render 'friends/lookup' %>
<% if @friendships.size > 0 %>
<table class="table table-striped">
<thead>
<tr>
<th colspan="3" class="page-header">
<h2>My Friends</h2>
</th>
</tr>
<tr>
<th>Name</th>
<th>Email</th>
<th>Actions</th>
</tr>
<thead>
<tbody>
<% @friendships.each do |friend| %>
<tr>
<td><%= friend.full_name %></td>
<td><%= friend.email %></td>
<td>
<%= link_to "View Profile", user_path(friend), class:"btn btn-primary btn-xs" %>
<%= link_to 'Remove Friend', friendship_path(friend), :method => :delete,
:data => {:confirm => "Are you sure?" },
:class => "btn btn-xs btn-danger" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<div class="row col-lg-12">
<p class="lead"> You don't have any friends yet. Please add some!</p>
</div>
<% end %>
Rails.application.routes.draw do
get 'user/registrations'
devise_for :users, :controllers => {:registrations => "user/registrations"}
get 'welcome/index'
resources :user_stocks, except: [:show, :edit, :update]
resources :users, only: [:show]
resources :friendships
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
#root 'welcome#index'
root 'welcome#index'
get 'my_portfolio', to:"users#my_portfolio"
get 'search_stocks', to: "stocks#search"
get 'my_friends', to: "users#my_friends"
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
class UsersController < ApplicationController
def my_portfolio
@user_stocks = current_user.stocks
@user = current_user
end
def my_friends
@friendships = current_user.friends
end
end
@aidataguy
Copy link

Ok Ryan here it seems like you need to put your file my_friends.html.erb under the users views.

As you are trying to get 'my_friends', to: "users#my_friends" which means rails server is looking for users controller my_friends action (users#my_friends)

@lrjbrual
Copy link
Author

lrjbrual commented Apr 2, 2016

Error is still:

ActionView::MissingTemplate in Users#my_friends
Showing /home/ubuntu/ruby-projects/finance-tracker/app/views/users/my_friends.html.erb where line #1 raised:

Missing partial friends/_lookup with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:

  • "/home/ubuntu/ruby-projects/finance-tracker/app/views"
  • "/usr/local/rvm/gems/ruby-2.3.0/gems/devise-bootstrap-views-0.0.8/app/views"
  • "/usr/local/rvm/gems/ruby-2.3.0/gems/twitter-bootstrap-rails-3.2.2/app/views"
  • "/usr/local/rvm/gems/ruby-2.3.0/gems/devise-3.5.6/app/views"
    Extracted source (around line #1):
    <%= render 'friends/lookup' %>
    <% if @friendships.size > 0 %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment