问题
I am a total novice (Please read my profile) and started following a Ruby on Rails tutorial but am stock half way.
The tutorial is here
http://12devs.co.uk/articles/writing-a-web-application-with-ruby-on-rails/
Halfway the page, it started introducing devise gem. Which I installed without a problem.
I followed the instructions up to "Devise also told us to check five steps to complete the setup:"
I don't understand what to do / where to add the following steps
1)define a root_url in config/routes.rb. Fow now, we can achieve this by pointing BookmarksController#index to the root of the site:
Bookmarks::Application.routes.draw do # [...] root ‘bookmarks#index’
[...] end
!What code do I exactly put inside the routes.rb file? and where? I have copy pasted the above in a random location in the file but I am aware this is not the write code. As there are comments and there is meant to be something instead on [...] PLEASE HELP
2)add the two pieces of html in app/views/layouts/application.html.erb. This file is the main layout your Rails app.
!Where are the HTML codes I need to enter? And what is that code? I cannot find any codes to insert
Your help is really really appreciated.
Thank you Sam
回答1:
- Open
config/routes.rb
and addroot :to => "bookmarks#index"
config/routes.rb
Rails.application.routes.draw do
root :to => "bookmarks#index"
end
- Add the two pieces of html in
app/views/layouts/application.html.erb
app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Beautify</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<!-- two pieces -->
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<!-- end two pieces -->
<%= yield %>
</body>
</html>
:)
来源:https://stackoverflow.com/questions/33809022/ruby-on-rails-tutorial-route-url-and-html-i-am-stock