###前提・実現したいこと
投稿を消去して消して、一覧に戻りたい
###発生している問題・エラーメッセージ
何も起きない
###該当のソースコード
class RestaurantController < ApplicationController before_action :set_restaurant, only: [:show, :edit, :update, :destroy] def top times = Time.zone.now @time = times.strftime("%H:%M") end def new end def create @restaurant = Restaurant.new @restaurant.name = params[:name] @restaurant.url = params[:url] @restaurant.start_time=params[:start_time] @restaurant.end_time=params[:end_time] @restaurant.location = params[:location] @restaurant.save redirect_to restaurant_path(@restaurant.id) end def edit end def index t = Time.zone.now.to_s(:time) @restaurants =Restaurant.where(' ? < end_time',t) end def update @restaurant.name = params[:name] @restaurant.url = params[:url] @restaurant.start_time = params[:start_time] @restaurant.end_time = params[:end_time] @restaurant.location = params[:location] @restaurant.save redirect_to restaurant_path(@restaurant.id) end def show end def set_restaurant @restaurant = Restaurant.find(params[:id]) end def destroy @restaurant.destroy redirect_to restaurants_path end end
<h2>店名</h2> <p><%= @restaurant.name %></p> <h2>内容</h2> <h3>営業時間</h3> <p><%= @restaurant.start_time %> ~ <%= @restaurant.end_time %></p> <h3>場所</h3> <p><%= @restaurant.location%><p> <h3>url</h3> <p><%= @restaurant.url%><p> <%= link_to "一覧へ", restaurants_path,class: "btn all-btn" %> <%= link_to "編集", edit_restaurant_path, class: "btn edit-btn" %> <%= link_to "削除", destroy_restaurant_path,class: "btn destroy-btn", "data-confirm" => "本当に削除しますか?" %>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/28 10:40