Rails4で使用できるcmsをいろいろ試しています。
comfortable-mexican-sofa1.12.1をインストールする手順をまとめました。
1)アプリケーション作成
$ rails new sofa
$ cd sofa
$ vi Gemfile
gem ‘therubyracer’, platforms: :ruby
2)comfortable-mexican-sofaをインストール
①Gemfile修正
gem ‘comfortable_mexican_sofa’, ‘~> 1.12.0’
②インストール
$ bundle install
: Installing bootstrap_form (2.1.1) : Installing codemirror-rails (4.2) : Installing kaminari (0.16.0) : Installing tinymce-rails (4.0.28.1) Installing comfortable_mexican_sofa (1.12.1)
3)初期セットアップ
①下記コマンド実行
$ rails generate comfy:cms
create db/migrate/20140611015107_create_cms.rb create config/initializers/comfortable_mexican_sofa.rb route comfy_route :cms_admin, :path => '/admin' # Make sure this routeset is defined last comfy_route :cms, :path => '/', :sitemap => false create db/cms_fixtures create db/cms_fixtures/sample-site/categories/files.yml create db/cms_fixtures/sample-site/categories/pages.yml create db/cms_fixtures/sample-site/categories/snippets.yml create db/cms_fixtures/sample-site/files/_sample.jpg.yml create db/cms_fixtures/sample-site/files/sample.jpg create db/cms_fixtures/sample-site/layouts/default/attributes.yml create db/cms_fixtures/sample-site/layouts/default/content.html create db/cms_fixtures/sample-site/layouts/default/javascript.js create db/cms_fixtures/sample-site/layouts/default/nested/attributes.yml create db/cms_fixtures/sample-site/layouts/default/nested/content.haml create db/cms_fixtures/sample-site/layouts/default/nested/javascript.js create db/cms_fixtures/sample-site/layouts/default/nested/stylesheet.css create db/cms_fixtures/sample-site/layouts/default/stylesheet.css create db/cms_fixtures/sample-site/pages/index/attributes.yml create db/cms_fixtures/sample-site/pages/index/child/attributes.yml create db/cms_fixtures/sample-site/pages/index/child/left.haml create db/cms_fixtures/sample-site/pages/index/child/right.html create db/cms_fixtures/sample-site/pages/index/child/thumbnail.png create db/cms_fixtures/sample-site/pages/index/content.html create db/cms_fixtures/sample-site/snippets/default/attributes.yml create db/cms_fixtures/sample-site/snippets/default/content.html create app/assets/javascripts/comfortable_mexican_sofa/admin create app/assets/javascripts/comfortable_mexican_sofa/admin/application.js create app/assets/stylesheets/comfortable_mexican_sofa/admin create app/assets/stylesheets/comfortable_mexican_sofa/admin/application.css Hey! Everything is almost done. Please don't forget to * run migrations -> `rake db:migrate` After that go to http://your-awesome-app/admin to start populating content. Default username and password are: username // password
②マイグレーション実行
$ rake db:migrate
== 20140611015107 CreateCms: migrating ======================================== -- create_table(:comfy_cms_sites) -> 0.0181s -- add_index(:comfy_cms_sites, :hostname) -> 0.0004s -- add_index(:comfy_cms_sites, :is_mirrored) -> 0.0007s -- create_table(:comfy_cms_layouts) -> 0.0010s -- add_index(:comfy_cms_layouts, [:parent_id, :position]) -> 0.0004s -- add_index(:comfy_cms_layouts, [:site_id, :identifier], {:unique=>true}) -> 0.0007s -- create_table(:comfy_cms_pages) -> 0.0010s -- add_index(:comfy_cms_pages, [:site_id, :full_path]) -> 0.0004s -- add_index(:comfy_cms_pages, [:parent_id, :position]) -> 0.0006s -- create_table(:comfy_cms_blocks) -> 0.0006s -- add_index(:comfy_cms_blocks, [:identifier]) -> 0.0004s -- add_index(:comfy_cms_blocks, [:blockable_id, :blockable_type]) -> 0.0007s -- create_table(:comfy_cms_snippets) -> 0.0007s -- add_index(:comfy_cms_snippets, [:site_id, :identifier], {:unique=>true}) -> 0.0004s -- add_index(:comfy_cms_snippets, [:site_id, :position]) -> 0.0006s -- create_table(:comfy_cms_files) -> 0.0008s -- add_index(:comfy_cms_files, [:site_id, :label]) -> 0.0004s -- add_index(:comfy_cms_files, [:site_id, :file_file_name]) -> 0.0006s -- add_index(:comfy_cms_files, [:site_id, :position]) -> 0.0007s -- add_index(:comfy_cms_files, [:site_id, :block_id]) -> 0.0008s -- create_table(:comfy_cms_revisions, {:force=>true}) -> 0.0007s -- add_index(:comfy_cms_revisions, [:record_type, :record_id, :created_at], {:name=>"index_cms_revisions_on_rtype_and_rid_and_created_at"}) -> 0.0005s -- create_table(:comfy_cms_categories, {:force=>true}) -> 0.0007s -- add_index(:comfy_cms_categories, [:site_id, :categorized_type, :label], {:unique=>true, :name=>"index_cms_categories_on_site_id_and_cat_type_and_label"}) -> 0.0005s -- create_table(:comfy_cms_categorizations, {:force=>true}) -> 0.0007s -- add_index(:comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], {:unique=>true, :name=>"index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id"}) -> 0.0005s == 20140611015107 CreateCms: migrated (0.0353s) ===============================
4)ログイン確認
①Webサーバー起動
$ rails s &
②ブラウザでhttp://localhost:3000/adminへアクセス
③デフォルトのユーザー名、パスワードを入力
username、password
④サイト作成
“New Site”画面へ遷移。下記項目を入力してサイトを作成
・Label サイト名
・Identifier
・Hostname
・Path ルートパス
・Language 日本語
⑤新規レイアウト作成
“新規レイアウト”画面へ遷移。下記項目を入力してレイアウトを作成
・レイアウト名
・Identifier
・アプリケーションレイアウト
・コンテンツ
・スタイルシート
・JavaScript
とりあえず、マニュアルに例示されていた下記コードをコンテンツに設定して作成してみました。
<html> <body> <h1>{_{ cms:page:header:string }}</h1> {_{ cms:page:content:rich_text }} </body> </html>