-
-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permit fails in 3.1.1 #929
Comments
Could this be related to #902? In other words, when |
This is the controller: # frozen_string_literal: true
module V1
class NotesController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
def create
note = current_user.notes.build(note_params)
tag_note(note) if tags_param?
note.save ? render(json: note) : render_validation_failed(note)
end
def show
render json: find_note
end
def index
render json: filter_notes
end
def update
note = find_note
if note.update(note_params)
tag_note(note) if tags_param?
render json: note
else
render_validation_failed(note)
end
end
def destroy
find_note.destroy ? head(:no_content) : render_not_found
end
private
def find_note
current_user.notes.find(params[:id])
end
def note_params
params.require(:note).permit(:title, :body)
end
def render_not_found
render json: {message: 'Record not found'}, status: :not_found
end
def render_validation_failed(note)
render json: {message: 'Validation failed', errors: note.errors.full_messages},
status: :unprocessable_entity
end
def filter_notes
current_user.notes
.title_matches(params[:title])
.body_matches(params[:body])
.tag_matches(params[:tag])
.any_matches(params[:any])
.order(:created_at)
end
def tag_note(note)
current_user.tag(note, with: params[:note][:tags], on: :tags)
end
def tags_param?
params[:note].key?(:tags)
end
end
end If in def note_params
binding.pry
params.require(:note).permit(:title, :body)
end the execution doesn't stop, so that means As for #902 I cannot determine if its related or not, but it possibly is. |
Revisiting old bugs and I'm not sure what to do about this, so I'm closing this. I'm happy to reopen this if others are still seeing it, though. |
Same issue here. I get
With binding.pry() in my Furthermore, given these two test cases:
The first one fails and the second one succeeds. Running shoulda-4.0.0. |
@pgiblock Since this is an old issue now, would you mind making a new issue to represent this so we can track it better? Additionally if you wouldn't mind sharing what's inside of your |
There have been problems with
permit
in the past. Currently I encounter the following problem:Given the specs:
I get the following failure:
Do I use the
permit
matcher wrong?The text was updated successfully, but these errors were encountered: