Saturday, 17 August 2013

How do I populate a table without adding a controller in Rails?

How do I populate a table without adding a controller in Rails?

I'm working on an app that allows users to create events and file them in
a category. While users fill in their own data for the event attributes,
they must choose from a list of pre-existing categories for which their
event will be filed under.
I want to hard-code these categories into the app but I'm not really sure
how to do that. I'd like to do it without a controller and view so I don't
have to add security features to keep users out.
These are my models:
class Category < ActiveRecord::Base
attr_accessible :name
has_many :events
end
class Event < ActiveRecord::Base
attr_accessible :address, :category_id, :cost, :title, :venue
belongs_to :category
validates :address, :category_id, :cost, :title, :venue, presence: true
end

No comments:

Post a Comment