-
Couldn't load subscription status.
- Fork 5
Generator adminpanel:resource
Jose Ramon edited this page Mar 12, 2015
·
9 revisions
To create a resource just run the resource command, with
rails g adminpanel:resource guitar description:wysiwyg price:float category:belongs_to release_date:datepicker
of course, you can choose what parameters to send. The list of supported parameters is:
field # no value given defaults to string
field:string
field:wysiwyg
field:float
field:integer
field:boolean
field:datepicker
field:file # when a resource have a single attachment.
category:has_many # when the resource you're creating has_many Adminpanel::Category
category:belongs_to # when the resource you're creating belongs_to Adminpanel::Category
field is the name of the field that you want in the database. This will make the migration, create the necessary files with the necessary information, after this you should migrate the database, and restart your server and be able to enter "/adminpanel/yourmodel" to start creating records.
Note: Every resource needs an instance method called name even it's only
def name
return '' # you can generate the name from other attributes too.
end