Skip to content

Commit 28ff316

Browse files
author
Innocent Amadi
committed
Add welcome index
1 parent 75e3652 commit 28ff316

17 files changed

+92
-9
lines changed

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ gem 'rails', '4.2.3'
77
gem 'sqlite3'
88
# Use SCSS for stylesheets
99
gem 'sass-rails', '~> 5.0'
10+
11+
# Use materialize
12+
gem 'materialize-sass'
13+
1014
# Use Uglifier as compressor for JavaScript assets
1115
gem 'uglifier', '>= 1.3.0'
1216
# Use CoffeeScript for .coffee assets and views

Gemfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ GEM
102102
lumberjack (1.0.9)
103103
mail (2.6.3)
104104
mime-types (>= 1.16, < 3)
105+
materialize-sass (0.97.0)
106+
sass (~> 3.3)
105107
method_source (0.8.2)
106108
mime-types (2.6.1)
107109
mini_portile (0.6.2)
@@ -234,6 +236,7 @@ DEPENDENCIES
234236
guard-rspec
235237
jbuilder (~> 2.0)
236238
jquery-rails
239+
materialize-sass
237240
rails (= 4.2.3)
238241
rspec-rails
239242
sass-rails (~> 5.0)
@@ -244,6 +247,3 @@ DEPENDENCIES
244247
tzinfo-data
245248
uglifier (>= 1.3.0)
246249
web-console (~> 2.0)
247-
248-
BUNDLED WITH
249-
1.10.5

Guardfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# * zeus: 'zeus rspec' (requires the server to be started separately)
2525
# * 'just' rspec: 'rspec'
2626
#guard :rspec, cmd: "bin/rspec", all_on_start: true do
27-
guard :rspec, cmd: "bundle exec rspec", all_on_start: true do
27+
guard :rspec, cmd: "bundle exec rspec" do
2828
require "guard/rspec/dsl"
2929
dsl = Guard::RSpec::Dsl.new(self)
3030

app/assets/javascripts/application.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
//= require jquery
1414
//= require jquery_ujs
1515
//= require turbolinks
16+
//= require materialize-sprockets
1617
//= require_tree .

app/assets/javascripts/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$( document ).ready(function() {
2+
$(".dropdown-button").dropdown();
3+
});

app/assets/javascripts/welcome.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/application.css app/assets/stylesheets/application.scss

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
*= require_tree .
1414
*= require_self
1515
*/
16+

app/assets/stylesheets/welcome.scss

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Place all the styles related to the Welcome controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
4+
@import "materialize";

app/controllers/foods_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def destroy
4545
if @admin
4646
food = Food.find(food_params[:id])
4747
if !food.nil?
48-
render html: food.destroy! ? flash[:notice]: "Food deleted successfully" : "Error! #{food.errors.messages}"
48+
render html: food.destroy! ? flash[:notice]="Food deleted successfully" : "Error! #{food.errors.messages}"
4949
else
5050
render html: "Food with id: #{food_params[:id]} doesn't exist!"
5151
end

app/controllers/welcome_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class WelcomeController < ApplicationController
2+
def index
3+
end
4+
end

app/helpers/welcome_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module WelcomeHelper
2+
end

app/views/layouts/application.html.erb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<%= csrf_meta_tags %>
88
</head>
99
<body>
10-
11-
<%= yield %>
12-
10+
<div class="container main">
11+
<%= yield %>
12+
</div><!-- end of container main-->
1313
</body>
1414
</html>

app/views/welcome/index.html.erb

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<header>
2+
3+
<ul id="dropdown1" class="dropdown-content">
4+
<li><a href="#!">one</a></li>
5+
<li><a href="#!">two</a></li>
6+
<li class="divider"></li>
7+
<li><a href="#!">three</a></li>
8+
</ul>
9+
<nav>
10+
<div class="nav-wrapper">
11+
<a href="#!" class="brand-logo">Logo</a>
12+
<ul class="right hide-on-med-and-down">
13+
14+
<li><a href="sass.html"><i class="material-icons">search</i></a></li>
15+
<li><a href="badges.html"><i class="material-icons">view_module</i></a></li>
16+
<li><a href="collapsible.html"><i class="material-icons">refresh</i></a></li>
17+
<li><a href="mobile.html"><i class="material-icons">more_vert</i></a></li
18+
19+
<li><a href="sass.html">Sass</a></li>
20+
<li><a href="badges.html">Components</a></li>
21+
<!-- Dropdown Trigger -->
22+
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a></li>
23+
</ul>
24+
</div>
25+
</nav>
26+
</div>
27+
</header>

config/routes.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Rails.application.routes.draw do
2+
get 'welcome/index'
3+
24
resources :foods
35

46
# The priority is based upon order of creation: first created -> highest priority.
57
# See how all your routes lay out with "rake routes".
68

79
# You can have the root of your site routed with "root"
8-
# root 'welcome#index'
10+
root 'welcome#index'
911

1012
# Example of regular route:
1113
# get 'products/:id' => 'catalog#view'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe WelcomeController, type: :controller do
4+
5+
describe "GET #index" do
6+
it "returns http success" do
7+
get :index
8+
expect(response).to have_http_status(:success)
9+
end
10+
end
11+
12+
end

spec/helpers/welcome_helper_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'rails_helper'
2+
3+
# Specs in this file have access to a helper object that includes
4+
# the WelcomeHelper. For example:
5+
#
6+
# describe WelcomeHelper do
7+
# describe "string concat" do
8+
# it "concats two strings with spaces" do
9+
# expect(helper.concat_strings("this","that")).to eq("this that")
10+
# end
11+
# end
12+
# end
13+
RSpec.describe WelcomeHelper, type: :helper do
14+
pending "add some examples to (or delete) #{__FILE__}"
15+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe "welcome/index.html.erb", type: :view do
4+
pending "add some examples to (or delete) #{__FILE__}"
5+
end

0 commit comments

Comments
 (0)