我尝试构建一个带有两个轴承的嵌套表单(= post do push do reviews) 我有这个错误:
我想知道我是否有成功创作的良好做法?
我的代码
查看/推手/显示:
AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
int audioSessionId = manager.generateAudioSessionId();
EqualizerModel.getInstance().setEqualizer(new Equalizer(0, audioSessionId));
评论/控制器:
<%= link_to 'Add comment', new_post_push_review_path(@push.post_id, @push) %>
查看/评论/新:
class ReviewsController < ApplicationController
before_action :authenticate_user!
before_action :find_post
before_action :find_push
def new
@review = Review.new
end
def create
@review = @post.push.reviews.create(review_params)
@review.post_id = @push.post_id
@review.push_id = @push.id
@review.user_id = current_user.id
if @review.save
redirect_to push_path(@push.post_id, @push)
else
render 'new'
end
end
private
def review_params
params.require(:review).permit(:rating, :comment)
end
def find_post
@post = Post.find(params[:post_id])
end
def find_push
@post = Post.find(params[:post_id])
@push = Push.find(params[:push_id])
end
end
&安培;路线:
<%= simple_form_for([@post, @post.push.reviews.build]) do |f| %>
<%= f.input :rating %>
<%= f.input :comment %>
<%= f.button :submit %>
<% end %>