How to setup spree_static_content with spree 3.X and rails 5 to generate static pages - ruby-on-rails-5

I have been trying to setup gem spree_static_content with spree 3.X and rails 5 but there are endless errors (migrations not running, gem dependencies) which are coming. Documentation is outdated and no help on any of the gems and spree commerce project. If someone has recently used these projects please share the debugging results.

When setting up spree_static_content gem with Rails 5.x and spree 3.x there are various errors you will get when you add only gem spree_static_content to your Gemfile.
Install following gems to your Gemfile and you will not get any error and will easily setup cms for static content for your application.
gem 'spree_static_content', github: 'spree-contrib/spree_static_content'
gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'activemodel-serializers-xml'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize'
Next, run following commands
bundle install
bundle exec rails g spree_i18n:install
bundle exec rails g spree_globalize:install
bundle exec rails g spree_static_content:install
Now, simply create pages from admin but don't forget to select the store-name checkbox for route to work for spree 3.x.

Related

Spree-social and omniauth

I am new to ruby and have spree-ecommerce application on spree .70 . I am trying to add Facebook Authentication using spree-social. Install request fails , when I follow exact steps. Here is what I get:
Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile.
I see same error even after running gem install omniauth
I had the same problem but I resolved it by watching the video tutorial at this address http://railscasts.com/episodes/241-simple-omniauth. It shows an introduction to OmniAuth.

Rails application as a gem

Suppose I have a rails application. What should I do to create a gem from it and distribute it to heroku (for example)?

Use Haml in rails plugin

I have made a mountable plugin using haml as template. I have added haml and haml-rails in my gemspec.
I use it in a project, I add it in my Gemfile as follows:
gem 'my_plugin', :git=> "git#github.com:lishoubo/my_plugin.git"
after execute bundle install, I see the haml and haml-rails have been installed.
But when I start the server, It prompts error:
Missing template
It seems the the project can not load haml gem event it install them. I guess it because the haml gems are installed for plugin not for the project. So I add haml and haml-rails to project Gemfile. It dose work.
However, I do not think it needs to add haml gem "again" to project Gemfile. Because I use a plugin, and this plugin uses haml, why I should add it to my Gemfile?
Does anyone know why?

PDF prawnto are not working with rails 3.2.8

we are using prawn to generate pdf file in our rails 3 app. Now after upgrading to rails 3.2.8, there is a problem with rails plugin prawnto. Here is the errror:
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them o
ut and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes
for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at D:/rails_proj/
emclab-failed2/config/environment.rb:5)
DEPRECATION WARNING: ActiveSupport::Memoizable is deprecated and will be removed in future releases,simply use Ruby memoization pattern inst
ead. (called from extend at D:/rails_proj/emclab-failed2/vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb:5)
D:/rails_proj/emclab-failed2/vendor/plugins/prawnto/lib/prawnto/template_handlers/base.rb:3:in `<module:TemplateHandlers>': uninitialized co
nstant ActionView::TemplateHandler (NameError)
Even rails server can not be started. Is there a way to fix this problem? thanks.
Prawn is a ruby gem and is not depending on prawnto to work with rails. Here is a post by aniket to use prawn directly in rails 3.2. We followed the instruction and it works in rails 3.2.8 as well. Check it out if you have the same compatible issue with prawnto.

Editing a gem definition on HEROKU (opentok)

quick question about Heroku. My app is using a gem called opentok. To function outside of a "sandbox" mode, the app requires changing an API link in a gem file called opentok.rb. I did that locally and the app works fine. however, when I deploy to heroku, the app does not work because heroku looks at my gem file and gets the unmodified gem lib of opentok which then runs my app on the heroku server in sandbox mode.
Is there a way I can access the opentok gem file (opentok.rb) on the heroku server and edit it with gvim from a console?
Thank you!!
Unpack the gem to your vendor directory, edit it as you require, then tell Bundler where to retrieve the gem from.
Command line:
gem unpack opentok-VERSION --target vendor/gems
Bundler:
gem 'opentok', :path => "vendor/gems/opentok-VERSION"
After you've done all this, do a bundle install, add the vendored Gem to your git repository, and push to heroku.
For the opentok gem, though, the api url can be passed directly as an option:
opentok = OpenTok::OpenTokSDK.new #api_key, #api_secret, :api_url => 'https://api.opentok.com/hl'
this feature is documented in the spec/opentok_spec.rb file. Look for:
it "should be possible to set the api url as an option" do
Thanks to Stijnster, the opentok gem creator, for pointing it out to me!