ActionController::ParameterMissing (param is missing or the value is empty: film):

后端 未结 3 971
轻奢々
轻奢々 2020-12-01 14:34

So, I\'m getting the following error when trying to visit the films page on my app:

ActionController::ParameterMissing (param is missing or the value is empt         


        
相关标签:
3条回答
  • 2020-12-01 15:15

    Why not use so:

    def creation_params
    params.permit(:film)
    end
    

    It working for me! ;)

    0 讨论(0)
  • 2020-12-01 15:21

    I have got this problem too when I use Angular JS form to send data to backend Rails 4. When I did not fill anything in angular js form, the error will show ActionController::ParameterMissing (param is missing or the value is empty:.

    I fix it by adding params.fetch(:film, {}) the strong parameter into:

    params.fetch(:film, {}).permit(:name, :sort_name, :description, :short_description, :meta_data,
        :poster, :amazon_link, :active, :trackable, :country_ids => [])
    

    I refer to code example to avoid ActionController::ParameterMissing (param is missing or the value is empty: film)

    I hope this will help you.

    0 讨论(0)
  • 2020-12-01 15:24

    This is happening because you have specified to require 'film' in your parameters through strong_params (specified above in your permitted_params code).

    Whatever the view side is doing (whether its a link or a form/etc.), its not passing its parameters nested under 'film'

    eg.) if you were to raise params.inspect in the controller action, you would see that there is no node for "film".

    Most likely what is wrong is that the form code you have on the view side is not set to nest these parameters properly, are you using a form_tag for example?

    0 讨论(0)
提交回复
热议问题