app/controllers/spotlight/roles_controller.rb in blacklight-spotlight-0.0.3 vs app/controllers/spotlight/roles_controller.rb in blacklight-spotlight-0.1.0

- old
+ new

@@ -3,27 +3,27 @@ before_filter :authenticate_user! load_and_authorize_resource :exhibit, class: Spotlight::Exhibit load_and_authorize_resource through: :exhibit, except: [:update_all] def index - # every admin should at least see themseleves - raise CanCan::AccessDenied if @roles.empty? - add_breadcrumb @exhibit.title, @exhibit + role = @exhibit.roles.build + authorize! :edit, role + + add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit) add_breadcrumb t(:'spotlight.administration.sidebar.users'), exhibit_roles_path(@exhibit) - @exhibit.roles.build end def update_all attrs = params.require(:exhibit).permit(:roles_attributes => [:id, :user_key, :role, :_destroy]) any_deleted = authorize_nested_attributes(attrs[:roles_attributes], Role) if @exhibit.update(attrs) - notice = any_deleted > 0 ? "User has been removed." : "User has been updated." + notice = any_deleted > 0 ? t(:'helpers.submit.role.destroyed') : t(:'helpers.submit.role.updated') redirect_to exhibit_roles_path(@exhibit), notice: notice else - flash[:alert] = "There was a problem saving the users." + flash[:alert] = t(:'helpers.submit.role.batch_error') render action: 'index' end end