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 6030997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:07:10+00:00 2026-05-23T05:07:10+00:00

I am creating a ruby on rails application which stores a users favourite publications

  • 0

I am creating a ruby on rails application which stores a users favourite publications and have stumbled across a problem and need some help.

The user is able to add as many different types of publications as they choose, such as books, movies, newspapers, articles etc. Each of those publication types has different attributes for example books may have an author and publisher, and a movie may have a director and producer. There are many attributes to a single publication.

My app currently looks like this: I have a publications resource which stores types of publications. There is a resource called attribs which stores all the attributes for a specific publication. And finally there there is a third resource called favourites.

class Publication < ActiveRecord::Base
 has_many :attribs

 # columns in this model => name, hidden

 # example ( :name => "movie", :hidden => false )
end

class Attrib < ActiveRecord::Base
 belongs_to :publication

 # columns in this model => publication_id, name, datatype

 # example (:publication_id => 1, :name => "Movie Title", :datatype => "string")
 # example (:publication_id => 1, :name => "Director", :datatype => "string")
end

class Favourite < ActiveRecord::Base

 # columns in this model => data, reason

 # example (:data => "[serialized form data]", :reason => "some reason why its a fav")

end

When a user creates a new favourite and selects a publication, I would like a form to be generated with the attributes the user chose for that specific publication.

Is there a way I can dynamically create a model/form with attributes that are stored in a database table?

As Formtastic is a dynamic form generator, can this be used to create the form?

To me this seems overly complicated, but I can’t figure another way to do it without having an awfully large amount of tables in my application.

  • 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-23T05:07:10+00:00Added an answer on May 23, 2026 at 5:07 am

    Formtastic and Simple Form gems need a model to be present to generate the forms for you. Check out this post here. Create a Tableless Model. Then create a Temporary Model using the tableless model. Then fetch the columns for Temporary Model from a table holding the column values for that model, like it is done for Foo in that link. Using an instance of the Temporary Class you can use Formtastic and generate form for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Ruby on Rails application, and I'm trying to create/login/logout users. This
I have a Rails application with several models-views-controllers which have some similar characteristics, for
I have built a Ruby on Rails (2.3.8) application that allows users to track
I'm practicing my Ruby on Rails by creating a simple application where users can
I'm creating a fast application with ruby on rails, and after doing a lot
I have been creating a website with Ruby on Rails, and will be hosting
I'm creating a website in Ruby on Rails, where users can login using RESTful
I have a ruby-on-rails application that wishes to utilise the tumblr gem for adding
I am creating a site in Ruby on Rails, I have two models a
im trying to understand the process of creating tables in ruby-on-rails 3. i have

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.