I have a simple ruby app that allows me to input, edit and update feedback data for students. I'd like to create a simple form, whereby I can choose from existing database parameters (using collection_select) and pump out content. So for instance, I'd like to be able to select the course and exercise and render associated contents. My database has contents associated as the following.

So, my main questions:

How can I create a form to use this database and simply select the qualities I'm looking for? Is there a way to do this somewhat randomly? so for instance, if I enter the course, exercise and type, it will randomly spit out one of the feedbacks with the associated markers? I am not sure how to randomize SELECT with ActiveRecord.


class CreateFeedbacks < ActiveRecord::Migration
  def change
create_table :feedbacks do |t|
      t.string :category
      t.text :content
      t.references :courses
      t.references :exercises


class Feedback < ActiveRecord::Base
  belongs_to :exercise
  belongs_to :course
  accepts_nested_attributes_for :exercise, :course

What the index looks like:


Again, I'm looking to create a simple form that will accept parameters I give it and then generate a custom feedback from the database. So for example, I can select course, exercise, category and it will spit out the content that's stored in the database. It's unclear to me if this can be achieved through the existing model or if I'd need to create another.

Related posts

Recent Viewed