This is the content of Chapter 5 of the Rails tutorial.
I want to display it like an image, but application.html.erb is not applied and only home.html.erb of static_pages is displayed.
My display contents started by rails s (localhost: 3000)
Description of home.html.erb Welcome to the Sample App This is the home page for the Ruby on Rails Tutorial sample application. <% = link_to "Sign up now!",'#', Class: "btn btn-lg btn-primary"%> <% = link_to image_tag ("rails.svg", alt: "Rails logo", width: "200px"), "https://rubyonrails.org/"%>
Description of application_controller.rb class ApplicationController</pre> <pre><code>Description of routes.rb Rails.application.routes.draw do root'static_pages # home' get'static_pages/home' get'static_pages/help' get'static_pages/about' end
What I tried
The contents of static_pages_contoroller.rb
-I wrote it by looking at the description that it is applied when layout: true is specified in the render description part of application_controller.rb, but it did not change.
def hello render html: "hello", layout: true ← This part end
・ I reviewed up to Chapter 5 of the Rails tutorial and checked if there were any mistakes in the file description. (I'm copying the file knowing that it's not good because I don't understand the file well.)
-Rails application.html.erb I tried some similar articles without being applied, but I couldn't improve.
-Search rails application.html.erb to reconfirm the role
・ Rails html. erb Search for something that I want to apply → I can't find a good siteWhat I think is the cause
-Unless layout is specified, application.html.erb is applied by default, and it is recognized that each content of the views file will be entered by the action in the<% = yield%>part (I would appreciate it if you point out if it is wrong). Is the default static_pages home.html.erb? ??
This is my first question, but if you have any advice such as this, I would like to refer to it and improve it, so I would appreciate it if you could tell me.
Answer # 1
What is common in such cases is
Wrong file name in application.html.erb
I edited the file but forgot to overwrite it
After that, there is also a pattern that can be fixed for some reason by restarting rails.
Answer # 2
Due to a description error in application_helpre.rb, an error occurred, so it was not reflected on the layout side.
Description of application_helper.rb Correct description module Application Helper #Returns the full title per page def full_title (page_title ='') base_title = "Ruby on Rails Tutorial Sample App" if page_title.empty? base_title else else page_title + "|" + base_title end end end
My wrong description
module Application Helper #Returns a complete other title for each page def full_title (page_title = ") ← Syntax error in quotation mark of argument part base_title = "Ruby on Rails Tuutorial Sample App" if page_title.empty? base_title else else page_title + "|" + base_title end end end
On the rails tutorial side, it was written in single quotes, but I deleted one double quote and only "" is in the correct state.
I was talking about'' for single quotes and "" for double quotes, but I was just thinking about filling in as in the example and whether it could be done, and I did not doubt that the basic syntax rules etc. were made. .. (I couldn't even copy it, but ...)
I'm sorry for making a noise due to a rudimentary mistake, thank you to all the people who answered! !! !! !! !!
Answer # 3
(Removed because it was a misunderstanding)
- ruby - rails tutorial chapter 13 delete does not work in the test of increasing/decreasing the number of posts with rspec
- ruby on rails 6 - rails tutorial chapter 14 about follow, unfollow, following? methods
- ruby on rails 6 - rails tutorial (6th edition, chapter 8, list 833) what is the difference between logged_in? and is_logged_in ?
- ruby on rails - rails tutorial chapter 13 cooperation between heroku and aws s3 region
- ruby on rails - in the rails tutorial (4th edition, chapter 5), the layout of only the login page is broken
- ruby - rails tutorial chapter 4 test fails
- ruby - rails tutorial chapter 2 (6th edition)
- windows - rails tutorial chapter 13 (1344) image upload in production environment does not work (s3, iam)
- ruby on rails - rails tutorial about git config settings
- ruby on rails 5 - the setup for everyday rails chapter 2 doesn't work (could not find shared context "project setup")
- ruby on rails - rails tutorial tests that should pass fail with an error [6th edition]
- ruby on rails 5 - if you get stuck in the required input, you don't want to see other validations
- cloud9 - rails tutorial chapter 12 problems that rails test does not pass
- ruby on rails - i want to write a rails tutorial test in rspec
- ruby on rails 6 - rails tutorial login [remember me] checkbox test
- ruby on rails - things associated with a foreign key cannot be called in view
- ruby on rails 6 - environment construction of ruby on rails
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - error in controller when transitioning with rails6 destory action
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby - i want to output all values at the beginning in the list search
- ruby - use form_with in rails to specify multiple models and save values
- ruby - data is not updated by update action rails
- ruby - criate action does not pass and is not saved
- ruby - schedulerb doesn't work well
- ruby - ssl_connect returned = 1 errno = 0 state = error: wrong version number
- ruby - i want to hide a specific record
- [ruby on rails] i want to implement a follow function, but the like button is not displayed in the view
- ruby - i want to collect the same records using rails group and get the value