Skip to content
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

answers_delimiter = "\r\n" #137

Open
john-huang-121 opened this issue May 14, 2019 · 3 comments
Open

answers_delimiter = "\r\n" #137

john-huang-121 opened this issue May 14, 2019 · 3 comments

Comments

@john-huang-121
Copy link

Hello!

I am a somewhat new rails programmer and just found your gem. Since the gem surveyor does not work for me and is way too old, I decided to play around with it.
While playing around with checkboxes, I ran into this problem.

Answer text is invalid (when the no checkbox in a yes/no question is checked and saved)

I narrowed it down to answer_text: "{"0"=>"0", "1"=>"no"}" and the issue being answers_delimiter not breaking up the submission correctly. When I changed "\r\n" to """ in the checkbox.rb model inside validate_answer it still doesn't work.

      def validate_answer(answer)
        super(answer)
        
        if rules[:presence] == "1" || answer.answer_text.present?
          answer.answer_text.split("\"").each do |value|
            answer.errors.add(:answer_text, :invalid) unless options.include?(value)
          end
        end
      end

Is there a way to fix this?

@john-huang-121
Copy link
Author

answer_text: "{\"0\"=>\"0\", \"1\"=>\"no\"}"

@stale
Copy link

stale bot commented Aug 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs for another 14 days. Thank you for your contributions.

@stale stale bot added the stale/wontfix label Aug 28, 2019
@stale stale bot closed this as completed Sep 11, 2019
@iffyuva iffyuva reopened this Jan 2, 2023
@bibstha
Copy link

bibstha commented Jun 11, 2024

Just wanted to leave a comment that "\r\n" is not a default behaviour on all browsers. On Mac, pressing enter will save only "|n" for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants