skess mousse
skess mousse

Reputation: 105

Spree installation -

I'm getting troubles to install spree. After installing all necessary gems, I launched the following commands :

rails _4.2.2_ new my_store
spree install my_store

I didn't get any error message but when I launch "rails s", I get the spree homepage with nothing else but "No products found" message.

Any clue about what could be wrong ?

thanks

Upvotes: 0

Views: 1992

Answers (4)

Bhargav Mehta
Bhargav Mehta

Reputation: 389

This is happening because rake is aborted and states and cities are not completely loaded.

There is a simple temporary solution to finish the rake and load all the sample data.

bundle exec rake db:drop

Then open the spree_core gem using

bundle open spree_core

Make the tweaks according to

spree_core/db/default/spree/countries.rb

require 'carmen'

Carmen::Country.all.map do |country|
  name = country.name
  iso3 = country.alpha_3_code
  iso = country.alpha_2_code
  iso_name = country.name.upcase
  numcode = country.numeric_code
  states_required = country.subregions?

  # country_inserts << [name, iso3, iso, iso_name, numcode, states_required].join(", ")
  Spree::Country.new(      :name => name,
      :iso3 => iso3,
      :iso => iso,
      :iso_name => iso_name,
      :numcode => numcode,
      :states_required => states_required
  ).save!
end

canada = Spree::Country.find_by(iso: "CA")
Spree::Config[:default_country_id] = canada.id

and

spree_core/db/default/spree/states.rb

connection = ActiveRecord::Base.connection
state_inserts = []

Spree::Country.where(states_required: true).each do |country|
  carmen_country = Carmen::Country.named(country.name)
  carmen_country.subregions.each do |subregion|
    name = connection.quote subregion.name
    abbr = connection.quote subregion.code
    country_id = connection.quote country.id

    state_inserts << [name, abbr, country_id].join(", ")
    Spree::State.new(:name => name, :abbr => abbr, :country_id => country_id).save!
  end
end

Then do

bundle exec rake db: create
bundle exec rake railties:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake spree_sample:load

Hope this solves you issue

Thank you

Reference:- https://askubuntu.com/questions/658049/spree-sample-data-fetch-giving-error-on-bundle-exec-rake-dbseed

Upvotes: -1

skess mousse
skess mousse

Reputation: 105

For sure something wrong with sqlite database but still don't know what ... I just created a new rails projects using mysql database :

rails new myproject -d mysql

Then :

bundle exec rake db:create

Finally :

spree install myproject

Thanks anyway for your help

Upvotes: 0

Arvind
Arvind

Reputation: 2781

simple spree installation does not give sample data or product , you have to install it via command bundle exec rake spree_sample:load

Upvotes: 2

Demi Magus
Demi Magus

Reputation: 3437

First of all you will need to install the spree gem in your environment if you haven't installed yet

gem install spree_cmd

Then you need to create a rails project

rails new my_store

After created your rails project run this command, this must be run outside of your project folder

spree install my_store

Finally it will prompt some questions in the terminal (if you want to run seed, which have the default data), you must answer that with a yes (y) or not (n) depending on what do you want to install (i'd recommend you to say yes to all)

And now you will have your Spree project running with all the default configuration and data.

Upvotes: 2

Related Questions