Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queues - Sahana Murthy - Media Ranker #40

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Index pages for different items created
Sahana Murthy committed Apr 11, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5a0a6e170014b387024e97ea61a7e8d068781957
3 changes: 3 additions & 0 deletions app/assets/javascripts/welcome.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
17 changes: 17 additions & 0 deletions app/assets/stylesheets/items.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.albums {
display: inline-block;
width: 30%;
vertical-align: top;
}

.movies {
display: inline-block;
width: 30%;
vertical-align: top;
}

.books {
display: inline-block;
width: 30%;
vertical-align: top;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the Items controller here.
// Place all the styles related to the welcome controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
15 changes: 15 additions & 0 deletions app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
@@ -2,8 +2,23 @@ class ItemsController < ApplicationController

def index
@items = Item.all
@albums = Item.where(category: "album")
@movies = Item.where(category: "movie")
@books = Item.where(category: "book")
end

def albums
@albums = Item.where(category: "album")
end

def books
@books = Item.where(category: "book")
end

def movies
@movies = Item.where(category: "movie")
end

def new
@item = Item.new
end
4 changes: 4 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class WelcomeController < ApplicationController
def index
end
end
2 changes: 2 additions & 0 deletions app/helpers/welcome_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module WelcomeHelper
end
1 change: 1 addition & 0 deletions app/models/item.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Item < ApplicationRecord
has_many :votes
end
9 changes: 9 additions & 0 deletions app/views/items/albums.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Albums</h1>
<ul>
<% @albums.each do |album| %>
<li>
<%=album.category%>, <%=album.title%>, <%=album.creator%>, <%=album.publication_year%>, <%=album.description%>
</li>
<% end %>
</ul>
<%= link_to 'Back to homepage', items_path %>
9 changes: 9 additions & 0 deletions app/views/items/books.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Books</h1>
<ul>
<% @books.each do |book| %>
<li>
<%=book.category%>, <%=book.title%>, <%=book.creator%>, <%=book.publication_year%>, <%=book.description%>
</li>
<% end %>
</ul>
<%= link_to 'Back to homepage', items_path %>
34 changes: 34 additions & 0 deletions app/views/items/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<h1>Media Ranker</h1>

<div class="movies">
<ul>
<% @movies.first(10).each do |movie| %>
<li>
<%=movie.category%>, <%=movie.title%>, <%=movie.creator%>, <%=movie.publication_year%>, <%=movie.description%>
</li>
<% end %>
</ul>
<%= link_to 'View More Movies', movies_path %>
</div>

<div class="books">
<ul>
<% @books.first(10).each do |book| %>
<li>
<%=book.category%>, <%=book.title%>, <%=book.creator%>, <%=book.publication_year%>, <%=book.description%>
</li>
<% end %>
</ul>
<%= link_to 'View More Books', books_path %>
</div>

<div class="albums">
<ul>
<% @albums.first(10).each do |album| %>
<li>
<%=album.category%>, <%=album.title%>, <%=album.creator%>, <%=album.publication_year%>, <%=album.description%>
</li>
<% end %>
</ul>
<%= link_to 'View More Albums', albums_path %>
</div>
9 changes: 9 additions & 0 deletions app/views/items/movies.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Movies</h1>
<ul>
<% @movies.each do |movie| %>
<li>
<%=movie.category%>, <%=movie.title%>, <%=movie.creator%>, <%=movie.publication_year%>, <%=movie.description%>
</li>
<% end %>
</ul>
<%= link_to 'Back to homepage', items_path %>
1 change: 1 addition & 0 deletions app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 6 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Rails.application.routes.draw do
resources :items
root "items#index"
get 'item/index'
get '/albums', to: 'items#albums', as: 'albums'
get '/books', to: 'items#books', as: 'books'
get '/movies', to: 'items#movies', as: 'movies'
resources :items
end
7 changes: 7 additions & 0 deletions test/controllers/welcome_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

describe WelcomeController do
# it "must be a real test" do
# flunk "Need real tests"
# end
end