Date : March 29 2020, 07:55 AM
should help you out I've come up with a JS based approach... I'm sure it's not the nicest way of doing it, but it works... In your view file, add something along the lines of this: <div id="client_approved_buttons" class="btn-group" data-toggle="buttons-radio">
<%= f.input : client_approved, as: :hidden %>
<a class="btn" data-value="1">Yes</a>
<a class="btn" data-value="0">No</a>
</div>
// make button toggles update hidden field
$('.btn-group a').on('click', function(event){
event.preventDefault();
var input = $(this).siblings('.control-group').find('input[type=hidden]');
if(input.length>0){
if(input.val().toString() !== $(this).data('value').toString()){
input.val($(this).data('value')).trigger('change');
}
}
});
|
How do I render check boxes with simple_form?
Date : March 29 2020, 07:55 AM
help you fix your problem simple_form will bind the selected options to the params[:content_type] variable. Note: content_type_options can also be a hash containing pairs of option/value. e.g. {'Blog' => 'blog', 'Editorial' => 'editorial', ...}
|
Rails has_many through with simple_form devise registration
Date : March 29 2020, 07:55 AM
This might help you As position_ids would be passed as an array, you need to update configure_permitted_parameters as below: def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :position_ids => []) }
end
|
Has_many through checkboxes (simple_form) not saving
Date : March 29 2020, 07:55 AM
Any of those help I am trying to sort comments into events using a has_many :through association using checkboxes however the selected events are not saved. Here are my models: , Try: def comment_params
params.require(:comment).permit(:post_id, :title, :event_ids => [])
end
|
How should I use nested attributes with simple_form, Rails 4, and has_many?
Date : March 29 2020, 07:55 AM
Any of those help A couple of changes should fix your issue: Ensure @user object has an application instance built before the form is rendered. Ensure you use form_builder.simple_fileds_for :applications, i.e. plural applications as your association is has_many. class UsersController < ApplicationController
def new
@user = User.new
@user.applications.build
end
end
<%= f.simple_fields_for :applications do |a| %>
<%= a.input :over_18, label: 'Are you over 18?', as: :radio_buttons %>
<% end %>
|