Rails params permit I am getting error -
i trying create form putting hidden value generating array :
"comment"=>{"comment"=>"sss", "feed_id"=>"354"}, "commit"=>"comment"}
but when trying use in controller permit produce error controller query :
@feeds= feed.find(params["comment"]["feed_id"])
this @feeds work great when trying use permit params showing error
actioncontroller::parametermissing (param missing or value empty: feed):
to permit using query :
def feed_params #params.require(:feed).permit(comment: :feed_id) params.require(:feed).permit(comment: [ :feed_id, :comment ]) #params[:market_place] end
when adding here in controller :
@feeds= feed.find(feed_params)
i getting error
actioncontroller::parametermissing (param missing or value empty: feed):
and form :
<%= form_for(@comment,:remote => true) |f| %> <%= f.text_area :comment, class:"form-control post required" %> <%= f.hidden_field :feed_id, {:value => @feed} %>
if write feed_params
require(:feed)
, rails expect params
have "feed"
key , value, not. form comments, define comment_params
method. define this:
def comment_params params.require(:comment).permit(:comment, :feed_id) end
and find feed this:
@feeds= feed.find(comment_params["feed_id"])
and should set.
Comments
Post a Comment