Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:58:44+00:00 2026-05-31T05:58:44+00:00

my problem is that I try to customize the formatastic view. But before I

  • 0

my problem is that I try to customize the formatastic view. But before I go into detail, I’ll explain my model.

I have 2 objects with a n:m relation Shop and Category

Shop model looks like that:

has_many :shop_categories, :class_name => "ShopCategory", :foreign_key => "shop_id"
has_many :categories, :through => :shop_categories, :source => :categories

Category model looks like that:

has_many :shop_categories, :class_name => "ShopCategory", :foreign_key => "category_id"
has_many :shops, :through => :shop_categories, :source => :shops

And of course my m to n table looks like

belongs_to :shops, :class_name => "Shop", :foreign_key => "shop_id"
belongs_to :categories, :class_name => "Category", :foreign_key => "category_id"

validates :shop_id, :presence => true
validates :category_id, :presence => true

This works fine and the following command in my Shop view will list all elements from categories within checkboxes:

<%= f.input :categories, :as => :check_boxes, :id => 'shop_categories' %>

Here is my problem:
Within categories I have a name for the category and a picture. Now I want to display the picture next to the selectbox.

I also tryed to use <% f.fields_for :categories do |category| %> but rails wont go through all category elements.

Is there a way to handle all Category elements with automatic checked objects?

If you need more information, i will be glad to give all what you need to understand the problem.
Thank you for any hint.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:58:45+00:00Added an answer on May 31, 2026 at 5:58 am

    Try overriding custom inputs:

    # app/inputs/collection_check_boxes_input.rb
    class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
      # [...]
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem that I could not solve. When I try to
My problem is that I have to set a variable in a try statement
Greetings, what is the problem that when I try to set credentials for my
my problem is that when i try to set the text of service1 and
One problem that I come across regularly and yet don't have a solution to
A problem that has frequently come up in my career is I have some
The problem that I have is somehow very specific. I have to implement a
My problem is that I try to upload an image and some text values
@Aniko points out that one way to view my problem is that I need
I have binary data in a file that I can read into a byte

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.