在我安装了bootstrapgem并rails server再次运行后,我收到此错误:
NoMethodError in Pages#welcome
undefined method `environment' for nil:NilClass
(in /Users/neilpatel/Desktop/Rails/prospects/app/assets/stylesheets/custom.css.scss)
Run Code Online (Sandbox Code Playgroud)
@import "bootstrap";
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<title>Prospects</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= link_to "Home", "/" %>
<%= link_to "About", "/about" %>
<%= yield %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Processing by PagesController#welcome as HTML
Rendered pages/welcome.html.erb within layouts/application (0.1ms)
Completed 500 Internal Server Error in …Run Code Online (Sandbox Code Playgroud) 试图在我的博客文章中添加验证,所以当你尝试添加少于5个字符的标题时,你会收到一条错误消息,但此刻我收到此错误消息 -
NameError in Posts#create
& undefined local variable or method `msg' for #<#<Class:0x007fce95ca04c0>:0x007fce95b4a300>
Run Code Online (Sandbox Code Playgroud)
new.html.erb
<div class = "container">
<h1> New Post </h1>
<%= form_for :post, url: posts_path do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do [msg] %>
<li><%= msg %></li> <error
<% end %>
</ul>
</div>
<% end %>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<%= f.label :text %><br>
<%= …Run Code Online (Sandbox Code Playgroud)