How to install Refinery CMS using Rails 4

2020-07-15 06:26发布

问题:

I previously never had a problem with Refinery. I was refreshing my knowledge by following along to the tutorial http://railscasts.com/episodes/332-refinery-cms-basics .Then when I created a new app with Refinery CMS, I got this error

Bundler could not find compatible versions for gem "actionmailer":
  In Gemfile:
    refinerycms (~> 2.1.0) ruby depends on
      actionmailer (< 3.3, >= 3.1.3) ruby

    rails (= 4.0.0) ruby depends on
      actionmailer (4.0.0)

But should not these things be there by default with the CMS? why would there be errors only now?

回答1:

Well, my five cents are that Refinery is not yet available for Rails 4:

  • Is there any cms for Rails 4?
  • http://refinerycms.com/
  • http://refinerycms.com/blog/refinery-cms-210-released

Best, Ben.



回答2:

The latest code supports Rails 4; the gem must be sourced from the master branch, until a release is made.

Git Issue #2428 - Rails 4 support

Add to your Gemfile:

gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'master'
gem 'refinerycms', github: 'refinery/refinerycms', branch: "master"
# Strong parameters is a new feature not used by Refinery
gem 'protected_attributes'

Do a:

$ bundle install 

Create a new Refinery app, the command will be different depending on what you want to do. For that there are a few guides that you can follow. In my case, I added it to an existing app with:

$ rails generate refinery:cms --fresh-installation

Start your server and go to: http://localhost:3000/refinery



回答3:

Simply initialize the application using:

rails new my_new_application -m http://refinerycms.com/t/edge

Behind the scenes: This command makes your application use the master branch of refinery, which supports Rails 4.

Update Although the above is the easiest and official way, it didn't totally work for me. I had to manually run the following command after the above one:

 rails generate refinery:cms --fresh-installation


回答4:

Looks like the rails4 branch has been getting a bit of love over the past few days:

https://github.com/refinery/refinerycms/tree/rails4

I will try it out and update with how I get on.



回答5:

OK, let's try and answer this one. This is the route I went down.

First, I installed the refinerycms gem.

gem install refinerycms

I then did a:

rbenv rehash

Then I followed the guide:

refinerycms rickrockstar

Bundler complained:

Bundler could not find compatible versions for gem "refinerycms-core":
  In Gemfile:
    refinerycms (~> 3.0) ruby depends on
      refinerycms-images (= 3.0.0) ruby depends on
        refinerycms-core (= 3.0.0) ruby

refinerycms (~> 3.0) ruby depends on
  refinerycms-images (= 3.0.0) ruby depends on
    refinerycms-core (= 3.0.0) ruby

refinerycms (~> 3.0) ruby depends on
  refinerycms-images (= 3.0.0) ruby depends on
    refinerycms-core (= 3.0.0) ruby

refinerycms (~> 3.0) ruby depends on
  refinerycms-images (= 3.0.0) ruby depends on
    refinerycms-core (= 3.0.0) ruby

refinerycms-wymeditor (>= 1.0.6, ~> 1.0) ruby depends on
  refinerycms-core (>= 3.0.0, ~> 3.0) ruby

refinerycms-acts-as-indexed (>= 1.0.0, ~> 1.0) ruby depends on
  refinerycms-core (~> 2.1.0) ruby

In my gemfile, I changed the following lines: gem 'rails', '4.2.4'

gem 'refinerycms'
gem 'refinerycms-acts-as-indexed'
gem 'refinerycms-wymeditor'

And this solved the issue.

I had to then do a:

bundle install

Then a:

rails generate refinery:cms --fresh-installation

I posted an issue on github and got the following answer from the RefineryTeam:

 It looks like the culprit was refinerycms-acts-as-indexed version - it should be ~> 2.0.1 to work with Refinery 3.0.0

https://github.com/refinery/refinerycms/issues/3072

Please also see this page where things might be running more smoothly than following the guide on Refinery's website. What is to be seen there is similar to Zuhaib Ali's answer above (in a bit more details).

Hope this helps