Rails4.1で『改訂新版 基礎Ruby on Rails』のコードで「ActiveModel::ForbiddenAttributesError」の対処Rails # 会員の新規登録 def create @member = Member.new(params[:member]) if @member.save redirect_to @member, notice: "会員を登録しました。" else render "new" end end # 会員情報の更新 def update params.permit! @member = Member.find(params[:id]) @member.assign_attributes(params[:member]) if @member.save redirect_to @member, notice: "会員情報を更新しました。"
![Rails4.1で『改訂新版 基礎Ruby on Rails』のコードで「ActiveModel::ForbiddenAttributesError」の対処 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/05f8a480a7847ebc774fb064768f14246e5fa1e3/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-9f5428127621718a910c8b63951390ad.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTkxNiZoPTMzNiZ0eHQ9UmFpbHM0LjElRTMlODElQTclRTMlODAlOEUlRTYlOTQlQjklRTglQTglODIlRTYlOTYlQjAlRTclODklODglRTMlODAlODAlRTUlOUYlQkElRTclQTQlOEVSdWJ5JTIwb24lMjBSYWlscyVFMyU4MCU4RiVFMyU4MSVBRSVFMyU4MiVCMyVFMyU4MyVCQyVFMyU4MyU4OSVFMyU4MSVBNyVFMyU4MCU4Q0FjdGl2ZU1vZGVsJTNBJTNBRm9yYmlkZGVuQXR0cmlidXRlc0Vycm9yJUUzJTgwJThEJUUzJTgxJUFFJUU1JUFGJUJFJUU1JTg3JUE2JnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmdHh0LWNsaXA9ZWxsaXBzaXMmdHh0LWFsaWduPWxlZnQlMkN0b3Amcz04ZTE4MjVmZmRlNWEzZDAzOTJmM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