I can't figure out what's wrong with my code (Rails 4):
parameters from the message:
{:name => "name"}
new action:
m=Menu.new(params.permit(:name))
The last line of this code generates "Cannot assign protected attributes to menu: name"
The standard way to use strong_parameters in Rails 4 is to create a private method in the controller that defines the allowed parameters. For instance:
def new @m = Menu.new(menu_params) end private def menu_params params.require(:menu).permit(:name, :etc, :etc) end
You can then remove the attr_accessible string from the model.
See:
http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html http://railscasts.com/episodes/371-strong-parameters
Source: https://habr.com/ru/post/952388/More articles:IOS Ad Hoc Crash - iosNSEvent keyCode map for virtual key code - macosExclamation mark randomly as a result of PHP-HTML-Email - htmlPrivate class in namespace - c ++Why is the reference to an automatic variable returned? - c ++Why is the marker window not displayed? - androidError in xml file premature end of data in tag - xmlAngularjs uses custom interpolation characters for scope - javascriptHow to skip "Hit back to start merge resolution tool" and automatically open mergetool - gitImplicit styles not working on user controls - resourcesAll Articles