布尔值不在Heroku上更新,但在本地工作

时间:2014-02-01 05:48:00

标签: ruby-on-rails ruby heroku

我的申请包含Items。它们具有status属性,它是一个布尔值。我通过rails g migration AddStatusToItems status:boolean将其添加到项目中。要在视图中将项目的状态显示为完成或待处理,我只需执行

<% if status? %>
Complete
<% else %>
Pending
<% end %>

哦是的,我还在控制器中的params哈希中添加了:status

它可以在本地运行,但在Heroku上,状态才会恢复到待处理状态。这是Heroku上的日志。我怎样才能使这个工作? enter image description here

 class ItemsController < ApplicationController
      before_action :set_item, only: [:show, :edit, :update, :destroy]
      before_action :authenticate_user!, except: [:index, :show, :upvote]

      # GET /items
      # GET /items.json
      def index
        @items = Item.all.order('created_at DESC')
      end

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

      # GET /items/new
      def new
        @item = Item.new
      end

      # GET /items/1/edit
      def edit
      end

      # POST /items
      # POST /items.json
      def create
        @item = current_user.items.new(item_params)


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

      # PATCH/PUT /items/1
      # PATCH/PUT /items/1.json
      def update
        respond_to do |format|
          if @item.update(item_params)
            format.html { redirect_to @item, notice: 'Item was successfully updated.' }
            format.json { head :no_content }
          else
            format.html { render action: 'edit' }
            format.json { render json: @item.errors, status: :unprocessable_entity }
          end
        end
      end

      # DELETE /items/1
      # DELETE /items/1.json
      def destroy
        @item.destroy
        respond_to do |format|
          format.html { redirect_to items_url }
          format.json { head :no_content }
        end
      end

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

        # Never trust parameters from the scary internet, only allow the white list through.
        def item_params
          params.require(:item).permit(:name, :quantity, :boughtfor, :soldfor, :user_id, :status)
        end
    end

0 个答案:

没有答案