2015-01-07 24 views
1

第一個字段「Cliche」拒絕顯示,「description」字段正確顯示。不知道我做錯了什麼。 enter image description here從視圖中丟失的第一個字段

common_linkers/show.html.erb

<div class="table-responsive"> 
    <table class="table"> 
    <tbody> 
     <tr> 
     <td><strong>Cliche:</strong></td> 
     <td <%= @common_linker.cliche %></td> 
     </tr> 
     <tr> 
     <td><strong>Description:</strong></td> 
     <td> <%= @common_linker.description %></td> 
     </tr> 
     <tr> 
     <td><strong>Created by:</strong></td> 
     <td><%= @common_linker.user.email %></td> 
     </tr> 

common_linkers_controller.rb

class CommonLinkersController < ApplicationController 
    before_action :set_common_linker, only: [:show, :edit, :update, :destroy, :votes] 
    before_action :set_movie 
    before_action :authenticate_user! 
    respond_to :html 

    def index 
    @common_linkers = CommonLinker.all 
    respond_with(@common_linkers) 
    end 

    def show 
    @common_linker = CommonLinker.find(params[:id]) 
    end 

    def vote 
     value = params[:type] == "up" ? 1 : -1 
    @common_linker = CommonLinker.find(params[:id]) 
    @common_linker.add_or_update_evaluation(:votes, value, current_user) 
     redirect_to :back, notice: "thanks for the vote" 
    end 


    def new 
    @common_linker = CommonLinker.new 
    respond_with(@common_linker) 
    end 

    def edit 
    end 

    def create 
    @common_linker = CommonLinker.new(common_linker_params) 
    @common_linker.user_id = current_user.id 
    @common_linker.movie_id = @movie.id 

    if @common_linker.save 
     redirect_to @movie 
    else 
     render 'new' 
    end 
    end 

    def update 
    @common_linker.update(common_linker_params) 
    respond_with(@common_linker) 
    end 

    def destroy 
    @common_linker.destroy 
    respond_with(@common_linker) 
    end 

    private 
    def set_common_linker 
    @common_linker = CommonLinker.find(params[:id]) 
    end 

    def set_movie 
     @movie = Movie.find(params[:movie_id]) 
    end 

    def common_linker_params 
    params.require(:common_linker).permit(:cliche, :description) 
    end 
end 

common_linker.rb

class CommonLinker < ActiveRecord::Base 
    belongs_to :user 
    belongs_to :movie 

    has_reputation :votes, source: :user, aggregated_by: :sum 
end 

的routes.rb

Rails.application.routes.draw do 

    devise_for :users 
    resources :movies do 
    resources :common_linkers do 
     member { post :vote } 

    end 
    end 
    root 'movies#index' 


end 

我還在學習,但我覺得我失去了一些東西大。任何幫助都會很棒。提前致謝。

回答

4

錯字:

<td <%= @common_linker.cliche %></td> 

應該是:

<td> <%= @common_linker.cliche %></td> 
+0

謝謝,我想這可能是一些愚蠢的。 – Jesse

相關問題