In refer to the instructions from the book:
* I created a separate topic branch "rails-flavored-ruby"
$ git checkout -b rails-flavored-ruby
* I defined a custom helper called full_title, to solve the problem of a missing page title.
app/helpers/application_helper.rb
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
end
* I simplified my application layout
app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
* I eliminated the code repeatation in Home, About and Contact for the test cases in the static pages controller:
test/controllers/static_pages_controller_test.rb
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
def setup
@base_title = "Ruby on Rails Tutorial Sample App"
end
test "should get root" do
get root_url
assert_response :success
end
test "should get home" do
get static_pages_home_url
assert_response :success
assert_select "title", "Ruby on Rails Tutorial Sample App"
end
test "should get help" do
get static_pages_help_url
assert_response :success
assert_select "title", "Help | #{@base_title}"
end
test "should get about" do
get static_pages_about_url
assert_response :success
assert_select "title", "About | #{@base_title}"
end
test "should get contact" do
get static_pages_contact_url
assert_response :success
assert_select "title", "Contact | #{@base_title}"
end
end
* And then, I read the introduction of Ruby programming language including methods, objects, class, def keyword, class keyword, HTML embedded Ruby ERB, data structures include arrays, ranges, hashes, inheritances, superclass, and etc. I did not do the Ruby programming exercises.
* After that, I commited the changes, and I merged the rails-flavoured-ruby branch to master:
$ git commit -am "Add a full_title helper"
$ git checkout master
$ git merge rails-flavored-ruby
* I did a sanity check before push:
$ rails test
5 runs, 9 assertions, 0 failures, 0 errors, 0 skips
* I pushed it up to Github - https://github.com/jimmy2046/sample_app:
$ git push
Nice post ! Thanks for sharing valuable information with us. Keep sharing.. Ruby on Rails Online Course Bangalore
ReplyDeletekayseriescortu.com - alacam.org - xescortun.com
ReplyDeletesmm panel
ReplyDeleteSmm panel
İs İlanlari
instagram takipçi satın al
HIRDAVATÇI BURADA
beyazesyateknikservisi.com.tr
SERVİS
tiktok jeton hilesi