ボールドテキストテラテイルにもあるようなfooterにお問い合わせフォームを作りたいのですがどうしたら良いでしょうか
ideaというコントローラーで作って<%= render partial: 'ideas/form' %>で呼び出しましたが
First argument in form cannot contain nil or be emptyとエラーになります。
lang
1class IdeasController < ApplicationController 2 before_action :set_idea, only: [:show, :edit, :update, :destroy] 3 4 # GET /ideas 5 # GET /ideas.json 6 def index 7 @ideas = Idea.all 8 @idea = Idea.new 9 end 10 11 # GET /ideas/1 12 # GET /ideas/1.json 13 def show 14 end 15 16 # GET /ideas/new 17 def new 18 @idea = Idea.new 19 end 20 21 # GET /ideas/1/edit 22 def edit 23 end 24 25 # POST /ideas 26 # POST /ideas.json 27 def create 28 @idea = Idea.new(idea_params) 29 30 respond_to do |format| 31 if @idea.save 32 format.html { redirect_to @idea, notice: 'Idea was successfully created.' } 33 format.json { render :show, status: :created, location: @idea } 34 else 35 format.html { render :new } 36 format.json { render json: @idea.errors, status: :unprocessable_entity } 37 end 38 end 39 end 40 41 # PATCH/PUT /ideas/1 42 # PATCH/PUT /ideas/1.json 43 def update 44 respond_to do |format| 45 if @idea.update(idea_params) 46 format.html { redirect_to @idea, notice: 'Idea was successfully updated.' } 47 format.json { render :show, status: :ok, location: @idea } 48 else 49 format.html { render :edit } 50 format.json { render json: @idea.errors, status: :unprocessable_entity } 51 end 52 end 53 end 54 55 # DELETE /ideas/1 56 # DELETE /ideas/1.json 57 def destroy 58 @idea.destroy 59 respond_to do |format| 60 format.html { redirect_to ideas_url, notice: 'Idea was successfully destroyed.' } 61 format.json { head :no_content } 62 end 63 end 64 65 private 66 # Use callbacks to share common setup or constraints between actions. 67 def set_idea 68 @idea = Idea.find(params[:id]) 69 end 70 71 # Never trust parameters from the scary internet, only allow the white list through. 72 def idea_params 73 params.require(:idea).permit(:body) 74 end 75end 76
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/02/14 14:07
2015/02/16 06:47