Ruby on rails tutorial : route_url and HTML - I am stock

依然范特西╮ 提交于 2019-12-12 03:23:40

问题


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:


  1. Open config/routes.rb and add root :to => "bookmarks#index"

config/routes.rb

Rails.application.routes.draw do
  root :to => "bookmarks#index"
end
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!