forked from oestrich/bookshare
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Books user is borrowing and books that are borrowed.
- Loading branch information
Showing
8 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class UsersController < ApplicationController | ||
|
||
load_and_authorize_resource | ||
|
||
def index | ||
|
||
end | ||
|
||
def borrowing | ||
@user = current_user | ||
@books = Book.where(:borrower_user_id => @user.id) | ||
|
||
end | ||
|
||
def borrowed | ||
@user = current_user | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
<h1> Books being borrowed </h1> | ||
<% current_user.locations.each do |location| %> | ||
<div class='location'> | ||
<% has_books = false %> | ||
<br /> | ||
<h1><b><%= link_to location.name, "/locations/#{location.id}" %></b></h1> | ||
<br /> | ||
<% location.books.each do |book| %> | ||
<% if book.borrower_user_id != nil %> | ||
<% has_books = true %> | ||
<% buser = User.find(book.borrower_user_id) %> | ||
<div class='book_borrowed'> | ||
<%= link_to image_tag(book.image_url), book, :title => "#{buser.first_name} #{buser.last_name} is borrowing this book." %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% if has_books == false %> | ||
No books are being borrowed in this location. | ||
<% end %> | ||
</div> | ||
<% end %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% @books.each do |book| %> | ||
<div class='book_borrowed'> | ||
<%= link_to image_tag(book.image_url), book, :title => "#{@user.first_name} #{@user.last_name} is borrowing this book." %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters