Rails4にrefineryを導入する手順をまとめました。
1)Gemをインストール
下記記事を参照し、Gemfileを設定しました。
http://stackoverflow.com/questions/18364951/how-to-install-refinery-cms-using-rails-4/20600134#20600134
$ vi Gemfile
gem 'refinerycms', github: 'refinery/refinerycms', branch: 'master' gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'master' gem 'friendly_id', github: 'norman/friendly_id', branch: 'master' gem 'friendly_id-globalize', github: 'norman/friendly_id-globalize', branch: 'master'
$ bundle install
2)既存のアプリにrefineryを追加
下記コマンドを実行します。
rails generate refinery:cms –fresh-installation
①開発中のアプリがある状態
下記エラーが発生して失敗しました。
rake aborted! ActiveRecord::RecordInvalid: バリデーションに失敗しました。 Friendlyは予約されています。
②新規アプリ(未開発)に設定
原因が分からなかったのであきらめて、新規にアプリ作成後のクリーン状態で実行したところ正常に実行できました。
$ rails generate refinery:cms –fresh-installation
remove app/views/layouts/application.html.erb gsub Gemfile append .gitignore insert app/assets/stylesheets/application.css create app/views/sitemap/index.xml.builder create config/database.yml.mysql create config/database.yml.postgresql create config/database.yml.sqlite3 create app/decorators/controllers/refinery/.gitkeep create app/decorators/models/refinery/.gitkeep insert config/routes.rb create config/initializers/refinery/core.rb : rake refinery_authentication:install:migrations Copied migration 20140425133946_create_refinerycms_authentication_schema.refinery_authentication.rb from refinery_authentication Copied migration 20140425133947_add_slug_to_refinery_users.refinery_authentication.rb from refinery_authentication Copied migration 20140425133948_add_full_name_to_refinery_users.refinery_authentication.rb from refinery_authentication create config/initializers/refinery/authentication.rb rake refinery_resources:install:migrations Copied migration 20140425133949_create_refinerycms_resources_schema.refinery_resources.rb from refinery_resources create config/initializers/refinery/resources.rb rake refinery_pages:install:migrations Copied migration 20140425133950_create_refinerycms_pages_schema.refinery_pages.rb from refinery_pages Copied migration 20140425133951_add_custom_slug_to_refinery_pages.refinery_pages.rb from refinery_pages create config/initializers/refinery/pages.rb append db/seeds.rb rake refinery_images:install:migrations Copied migration 20140425133952_create_refinerycms_images_schema.refinery_images.rb from refinery_images Copied migration 20140425133953_remove_image_ext_from_refinery_images.refinery_images.rb from refinery_images create config/initializers/refinery/images.rb create config/initializers/refinery/i18n.rb rake railties:install:migrations Copied migration 20140425133954_create_seo_meta.seo_meta.rb from seo_meta Copied migration 20140425133955_remove_meta_keywords_from_seo_meta.seo_meta.rb from seo_meta rake db:create db:migrate == CreateRefinerycmsAuthenticationSchema: migrating ========================== -- create_table(:refinery_roles_users, {:id=>false}) -> 0.0006s -- add_index(:refinery_roles_users, [:role_id, :user_id]) -> 0.0005s -- add_index(:refinery_roles_users, [:user_id, :role_id]) -> 0.0007s -- create_table(:refinery_roles) -> 0.0011s -- create_table(:refinery_user_plugins) -> 0.0006s -- add_index(:refinery_user_plugins, :name) -> 0.0004s -- add_index(:refinery_user_plugins, [:user_id, :name], {:unique=>true}) -> 0.0007s -- create_table(:refinery_users) -> 0.0010s -- add_index(:refinery_users, :id) -> 0.0005s == CreateRefinerycmsAuthenticationSchema: migrated (0.0067s) ================= == AddSlugToRefineryUsers: migrating ========================================= -- add_column(:refinery_users, :slug, :string) -> 0.0007s -- add_index(:refinery_users, :slug) -> 0.0006s == AddSlugToRefineryUsers: migrated (0.0015s) ================================ == AddFullNameToRefineryUsers: migrating ===================================== -- add_column(:refinery_users, :full_name, :string) -> 0.0006s == AddFullNameToRefineryUsers: migrated (0.0006s) ============================ == CreateRefinerycmsResourcesSchema: migrating =============================== -- create_table(:refinery_resources) -> 0.0011s == CreateRefinerycmsResourcesSchema: migrated (0.0012s) ====================== == CreateRefinerycmsPagesSchema: migrating =================================== -- create_table(:refinery_page_parts) -> 0.0009s -- add_index(:refinery_page_parts, :id) -> 0.0004s -- add_index(:refinery_page_parts, :refinery_page_id) -> 0.0007s -- create_table(:refinery_pages) -> 0.0030s -- add_index(:refinery_pages, :depth) -> 0.0005s -- add_index(:refinery_pages, :id) -> 0.0005s -- add_index(:refinery_pages, :lft) -> 0.0007s -- add_index(:refinery_pages, :parent_id) -> 0.0009s -- add_index(:refinery_pages, :rgt) -> 0.0010s == CreateRefinerycmsPagesSchema: migrated (0.0278s) ========================== == AddCustomSlugToRefineryPages: migrating =================================== == AddCustomSlugToRefineryPages: migrated (0.0012s) ========================== == CreateRefinerycmsImagesSchema: migrating ================================== -- create_table(:refinery_images) -> 0.0014s == CreateRefinerycmsImagesSchema: migrated (0.0015s) ========================= == RemoveImageExtFromRefineryImages: migrating =============================== -- remove_column(:refinery_images, :image_ext) -> 0.0051s == RemoveImageExtFromRefineryImages: migrated (0.0052s) ====================== == CreateSeoMeta: migrating ================================================== -- create_table(:seo_meta) -> 0.0009s -- add_index(:seo_meta, :id) -> 0.0005s -- add_index(:seo_meta, [:seo_meta_id, :seo_meta_type], {:name=>:id_type_index_on_seo_meta}) -> 0.0006s == CreateSeoMeta: migrated (0.0022s) ========================================= == RemoveMetaKeywordsFromSeoMeta: migrating ================================== -- remove_column(:seo_meta, :meta_keywords) -> 0.0077s == RemoveMetaKeywordsFromSeoMeta: migrated (0.0078s) ========================= rake db:seed
3)動作確認
①ブラウザで下記にアクセス
http://localhost:3000/refinery
②ユーザー登録
下記にリダイレクトし、ユーザー登録画面に遷移
http://localhost:3000/refinery/users/register
③ユーザー登録し、ログイン