Git bash (Msys2) не работает, но windows cmd работает - PullRequest
0 голосов
/ 10 апреля 2020

Привет, когда я запускаю rails s в git bash (Msys2), я получаю сообщение об ошибке. Но когда я запускаю его в windows cmd. Затем оно запустит приложение без этой ошибки и отобразит так, как должно. Я включу свой контроллер, вид, код маршрута и код модели. Спасибо за любую помощь. Работали над этим в течение последнего дня только для этой 1 проблемы.

Код ошибки при использовании Git Bash:

TweeetsController#index is missing a template for request formats: text/html

Код контроллера:

class TweeetsController < ApplicationController
  before_action :set_tweeet, only: [:show, :edit, :update, :destroy]

  # GET /tweeets
  # GET /tweeets.json
  def index
    @tweeets = Tweeet.all
  end

  # GET /tweeets/1
  # GET /tweeets/1.json
  def show
  end

  # GET /tweeets/new
  def new
    @tweeet = Tweeet.new
  end

  # GET /tweeets/1/edit
  def edit
  end

  # POST /tweeets
  # POST /tweeets.json
  def create
    @tweeet = Tweeet.new(tweeet_params)

    respond_to do |format|
      if @tweeet.save
        format.html { redirect_to @tweeet, notice: 'Tweeet was successfully created.' }
        format.json { render :show, status: :created, location: @tweeet }
      else
        format.html { render :new }
        format.json { render json: @tweeet.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /tweeets/1
  # PATCH/PUT /tweeets/1.json
  def update
    respond_to do |format|
      if @tweeet.update(tweeet_params)
        format.html { redirect_to @tweeet, notice: 'Tweeet was successfully updated.' }
        format.json { render :show, status: :ok, location: @tweeet }
      else
        format.html { render :edit }
        format.json { render json: @tweeet.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /tweeets/1
  # DELETE /tweeets/1.json
  def destroy
    @tweeet.destroy
    respond_to do |format|
      format.html { redirect_to tweeets_url, notice: 'Tweeet was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_tweeet
      @tweeet = Tweeet.find(params[:id])
    end

    # Only allow a list of trusted parameters through.
    def tweeet_params
      params.require(:tweeet).permit(:tweeet)
    end
end

<p id="notice"><%= notice %></p>

<h1>Tweeets</h1>

<table>
  <thead>
    <tr>
      <th>Tweeet</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @tweeets.each do |tweeet| %>
      <tr>
        <td><%= tweeet.tweeet %></td>
        <td><%= link_to 'Show', tweeet %></td>
        <td><%= link_to 'Edit', edit_tweeet_path(tweeet) %></td>
        <td><%= link_to 'Destroy', tweeet, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Tweeet', new_tweeet_path %>

Код маршрута:



resources :tweeets
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

  root "tweeets#index"

end

Код модели:


class Tweeet < ApplicationRecord
end

...