railstutorial.jp | Ruby on Rails Tutorial | Application Framework library
kandi X-RAY | railstutorial.jp Summary
kandi X-RAY | railstutorial.jp Summary
Ruby on Rails Tutorial in Japanese (2nd Edition)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of railstutorial.jp
railstutorial.jp Key Features
railstutorial.jp Examples and Code Snippets
Community Discussions
Trending Discussions on railstutorial.jp
QUESTION
I expected this code to return red because the title part of the view evaluates to "Home | Ruby on Rails Tutorial Sample App". But actually, green was returned. On the other hand, the title part of the view that the specification expects is "Ruby on Rails Tutorial Sample App". I don't know why this will happen.
application.html.haml is common layout.
...ANSWER
Answered 2020-Feb-23 at 13:29This happens because the default behavior of have_title
is to do a substring match - https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Node/DocumentMatchers:has_title%3F
If you want an exact match pass exact: true
expect(page).to have_title(@base_title.to_s, exact: true)
QUESTION
I'm a beginner. I'm in trouble because I can't settle an error.
error message
No route matches [GET] "/static_pages/home"
Rails.root: /home/ec2-user/environment/sample_app
Application Trace | Framework Trace | Full Trace
...ANSWER
Answered 2018-Sep-13 at 14:51It looks like, from your post, that your home.html.erb
template file is in the wrong place. There should be a folder called static_pages
inside app/views
. So inside app/views/static_pages/
is where your home.html.erb
file should be. Your code says it is inside the layouts
folder. Move it and it will work.
So, specifically, either create the folder static_pages
(if it does not exist) or move you home.html.erb file into the app/views/static_pages/
folder.
Just and FYI, if your other views (contact, about, etc) are in the layout
folder move them into static_pages
too. But leave the layout file in there.
Since you are a beginner I'll explain this a little more. When you set your routes you are telling rails where to find the files. So when you write something like get '/help', to: 'static_pages#help
what you telling rails is when the URL /help
is viewed serve up the file help.html.erb
in the static_pages
folder and it knows to look inside the app/views
folder by configuration. If you wanted to keep home.html.erb
where it is, you could just change you routes to root 'layouts#home'
and it should work, but since the view file is not a layout file that would not be the best solution. Hope this helps.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install railstutorial.jp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page