ruby as a ruby on rails web application with jquery used as the
- ruby: 1.8.7+, rubinus or jruby
- rubygems: recommended that you have the latest version installed
- database: sqlite3, mysql or postgresql
- imagemagick: recommended that you have the latest version installed
this may take some time to load
gem install refinerycms
Creat a new refinery project
After this you only need to start your application server and start browsing your cms.
Create a custom engine
If you need more than just static pages and want to add an entity and store it on the database you need to create your own engine. Refinery has one generator to do it, refinery:engine similar to the rails scaffold generator, we pass it the name of a resource and a list of attributes. In our example we'll create a "piano" engine with 3 attributes.
rails g refinery:engine piano name:string photo:image entity_data:date
The generator accepts the rails regular types and also has another one, the image type, using it refinery will automatically handle these images for us.
This command will generate an engine for us and will place it under a vendor/extensions/pianos directory.
app config db doc lib log public script tmp vendor assets extensions pianos* plugins
You would notice that your gemfile has been updated
gem 'refinerycms-i18n', '~> 2.0.0' # gem 'refinerycms-blog', '~> 2.0.0' # gem 'refinerycms-inquiries', '~> 2.0.0' # gem 'refinerycms-search', '~> 2.0.0' # gem 'refinerycms-page-images', '~> 2.0.0' gem 'refinerycms-pianos', :path => 'vendor/extensions'
There’s a new line at the bottom of this file which contains a gem that points to the vendor/extensions path.This is interesting; not only did the command generated an engine but it also turned it into a gem which is used in our application.This means that it’s easy to take the engine and turn it into a gem that we can use in other applications.There are several commented-out gems in the gemfile which are basically the same thing.Each one is a separate engine for extending refinery and can add functionality such as blog, searching and so on.
How it says on the log we need to run
rails generate refinery:pianos
This command generaties the migration to create the "pianos" table and adds a line to the seeds.
This line will add a new page to refinery for displaying "pianos" to the user.
Now we just need to migrate the database and load the seed data.
Our engine is now set up, after a server restart if we load the admin page we will see a new "pianos" tab that we can use to manage the piano entities.
rake db:migrate rake db:seed