我有以下内容:
class PhotoLibrariesController < ApplicationController
def create
@photo_library = PhotoLibrary.new(photo_library_params)
if @photo_library.save
respond_to do |format|
format.html { redirect_to photo_libraries_path }
format.js
end
else
flash[:alert] = 'Photo Library not created successfully'
render :new
end
end
def new
@photo_library = PhotoLibrary.new
end
def index
@photo_libraries = PhotoLibrary.all
end
private
def photo_library_params
params.require(:photo_library).permit( :title )
end
end
这总是导致:
WARNING: Can't mass-assign protected attributes for PhotoLibrary: title
app/controllers/photo_libraries_controller.rb:35:in `create'
我在这里做错了什么?为什么 strong_parameters 似乎不起作用?