Posts

Showing posts from July, 2015

Could not find generator 'refinery:engine'

First run "gem install refinerycms" Then add the following gem then problem will be resolve gem 'refinerycms',      '~> 3.0.0.dev', git: 'https://github.com/refinery/refinerycms.git' gem 'refinerycms-i18n', '~> 3.0.0.dev', git: 'https://github.com/refinery/refinerycms-i18n.git' Then run rails generate refinery:cms --fresh-installation

create our own gem in ruby on rails

$ gem install bundler     $ bundle gem dogeify   This will create following directories   $ tree dogeify dogeify ├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── dogeify.gemspec └── lib    ├── dogeify    │   └── version.rb    └── dogeify.rb         Let's first look at the gemspec file ( dogeify.gemspec in this case).    # coding: utf-8 lib = File .expand_path( '../lib' , __FILE_ _ ) $LOAD_PATH .unshift(lib) unless $LOAD_PATH . include ?(lib) require 'dogeify/version' Gem::Specification .new do |spec| spec.name = "dogeify" spec.version = Dogeify::VERSION spec.authors = [ "Matt Huggins" ] spec.email = [ "matt.huggins@gmail.com" ] spec.description = %q{Convert everyday boring English into doge speak!} spec.summary = %q{English to doge translations} spec.homepage = "" spec.license = "MIT" spec.files

List all countries with code

[       {:name => 'Åland Islands', :iso_code => 'AX'},       {:name => 'Albania', :iso_code => 'AL'},       {:name => 'Algeria', :iso_code => 'DZ'},       {:name => 'American Samoa', :iso_code => 'AS'},       {:name => 'Andorra', :iso_code => 'AD'},       {:name => 'Angola', :iso_code => 'AO'},       {:name => 'Anguilla', :iso_code => 'AI'},       {:name => 'Antarctica', :iso_code => 'AQ'},       {:name => 'Antigua and Barbuda', :iso_code => 'AG'},       {:name => 'Argentina', :iso_code => 'AR'},       {:name => 'Armenia', :iso_code => 'AM'},       {:name => 'Aruba', :iso_code => 'AW'},       {:name => 'Australia', :iso_code => 'AU'},       {:name => 'Austria', :iso_code => 'AT'},  

encode and decode image in Base64 in rails

require "base64" encoded_string = Base64.encode64(open("https://s3.amazonaws.com/cdn. yourwellnessroom.com/i/pillarimages/eat/E22.jpg") { |io| io.read }) decode_img= Base64.decode64(encoded_string)   File.open('image.png', 'wb') { |f| f.write(decode_img) }   user.image = image.png'   user.save

Facebook authentication with devise in ruby on rails

Image
Step 1: Preparing your Application    rails new omniauth-tutorial  And integrate devise Step 2: Creating a Provider  In order to add a provider to Omniauth, you will need to sign up as a developer on the provider’s site. Once you’ve signed up, you’ll be given two strings (sort of like a username and a password), that needs to be passed on to Omniauth. If you’re using an OpenID provider, then all you need is the OpenID URL. If you want to use Facebook authentication, head over to developers.facebook.com/apps and click on “Create New App”. Fill in all necessary information, and once finished, copy your App’s ID and Secret. Configuring Twitter is a bit more complicated on a development machine, since they don’t allow you to use “localhost” as a domain for callbacks. Configuring your development environment for this kind of thing is outside of the scope of this tutorial, however, I recommend you use Pow if you’re on a Mac. Add to your  Gemfile : gem ' o