13
Sono un po 'perso. Ho ottenuto l'errore Rails 4: ActiveModel :: ForbiddenAttributesError. Capisco che questo significa che devo consentire il passaggio degli articoli, cosa che ho fatto, ma mi manca qualcosa.ActiveModel :: ForbiddenAttributesError - Rails 4
Commenti Controller:
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to @post
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def comment_params
params.require(:comment).permit(:post_id, :comment, :body)
end
end
Creare Commenti migrazione
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.references :post
t.text :body
t.timestamps
end
end
def self.down
drop_table :comments
end
end
Che cosa mi manca qui? Fammi sapere se hai bisogno di vedere qualsiasi altro codice.
Grazie!
Blah! Sapevo che doveva essere banale. Grazie! –
Mi ha fatto inciampare anche da Rails 3, grazie! – Zach