0

I used simple_form and devise (RoR gems) to make a New User and Edit User form. I added a checkbox feature so that users can select what payment methods they accept. However, after filling up and updating the form, user page generates this dashes, zeroes and other symbols while also displaying the checked items.

Example: (When I updated the form, I checked "Debit Card" and "PayPal". This is what comes out:

Payment Methods Accepted: --- - Debit Card - PayPal - ''

I know this might be a silly question, but does anyone know how I can get rid of the unnecessary symbols? I'm a complete beginner in RoR and am really struggling to understand all the codes.

For my edit.html.erb (which is also what the user visits to view the profile page), I used the following codes:

    <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:method => :put, class: 'form-horizontal'}) do |f| %>
  <%= f.error_notification %>

<%= f.input :name %>
Payment Methods Accepted:
    <%= @user.paymode %>
<div class="checkboxes">
<p>
    <%= f.collection_check_boxes :paymode, [['Cash', 'Cash'] ,['Credit Card', 'Credit Card'] ,['Debit Card', 'Debit Card'] ,['PayPal', 'PayPal']], :first, :last, {:item_wrapper_class => 'checkbox_container'} %>
    </div>

This is then defined under my user.controller.rb file

    class UsersController < ApplicationController
      def show
       @user = User.find(params[:id])
end

Also, to give a quick background: I initially attempted to implement acts_as_taggable_on with simple_form and devise so that I could eventually filter users later on by paymode (payment methods). However, this did not work out, so I just simplified it to this. I removed all tagging-related codes after that. Would this have any relation to the symbols I'm getting?

Thanks and help would be greatly appreciated!

Dave Newton
  • 158,873
  • 26
  • 254
  • 302

1 Answers1

0

Without understanding what paymode actually is, it's difficult to say.

So far it sounds like you're directly displaying a collection of payment modes, e.g., calling .to_s on the enumeration.

You should loop over them and explicitly display each instead, roughly:

This assumes that each paymode is an associated object with something like an id and a human-readable name. This would explain at least some of the "garbage" output you're seeing.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302