小编Eoi*_*in 的帖子

带导轨的引导程序 6

我正在尝试让引导程序在我的 rails 6 Web 应用程序中工作,但它不起作用。我在 youtube 和这里​​学习了多个教程,但似乎没有任何效果。任何我可能出错的帮助将不胜感激。

Gemfile:(包括引导程序的前半部分)

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'
gem 'jquery-rails'
gem 'coffee-script-source', '~> 1.11', '>= 1.11.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'bootstrap-sass', '~> 3.4.1'
gem 'sass-rails', '>= 6'
Run Code Online (Sandbox Code Playgroud)

应用程序.js:

require("@rails/ujs").start()
require …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails twitter-bootstrap

5
推荐指数
1
解决办法
1103
查看次数

删除方法 rails 6

我制作了一个 Web 应用程序,允许用户添加编辑和删除文章。我遇到的问题是删除方法不起作用。当我点击想要删除的文章旁边的“删除”时,什么也没有发生,我也没有收到任何错误。我认为它充当 GET 方法而不是 DELETE 方法,但我不知道为什么它不起作用。

任何帮助将不胜感激!

文章_controller.rb

def destroy
  @article = Article.find(params[:id])
  @article.destroy
  redirect_to articles_path
end
Run Code Online (Sandbox Code Playgroud)

index.html.erb

<tbody>
  <% @articles.each do |article| %>
  <tr>
    <td><%= article.title %></td>
        <td><%= article.description %></td>

        <td><%= link_to 'Show', article_path(article) %></td>
        <td><%= link_to 'Edit', edit_article_path(article) %></td>
        <td><%= link_to 'Delete', articles_path(article), method: :delete, data: {confirm: "Are you sure?"} %></td>

  </tr>
  <% end %>
Run Code Online (Sandbox Code Playgroud)

单击删除时的控制台:

Started GET "/articles.5" for ::1 at 2020-03-26 16:45:32 +0000
Processing by ArticlesController#index as
  Rendering articles/index.html.erb within layouts/application
  Article Load (0.4ms)  SELECT …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails http-delete

0
推荐指数
1
解决办法
1463
查看次数