Skip to content

Instantly share code, notes, and snippets.

View rodrigoargumedo's full-sized avatar
🎯
Focusing

Rodrigo Argumedo rodrigoargumedo

🎯
Focusing
View GitHub Profile

Problem:

I have installed: ruby-2.0.0, PostgreSQL 9.2, now in Rails app when I execute:

  rake db:create, command I get:

PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template. : CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......

<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@site_username">
<meta name="twitter:creator" content="@creator_username">
{% if page.title %}
<meta name="twitter:title" content="{{ page.title }}">
{% else %}
<meta name="twitter:title" content="{{ site.title }}">
{% endif %}
{% if page.url %}
<meta name="twitter:url" content="{{ site.url }}{{ page.url }}">
@rodrigoargumedo
rodrigoargumedo / devise.rb
Created April 1, 2015 15:38
This explains how to resolve the 401 Unauthorized status code and redirect your twitter app.
# Lastly, Changing in OmniAuth.rb will affect this file too.
# Change this line in order to fully work and restart the server when you save this file.
# ...viola! You now have profit to make.
Devise.setup do |config|
config.omniauth :twitter, Rails.application.secrets.twitter_consumer_key, Rails.application.secrets.twitter_consumer_secret
end
# Let's say I want to return a route with id (Devise) without having
# Rails to complain that Mongoid needs to a id of some number.
# So, I have controller containing profiles in the files.
# It goes like..
ProfilesController < ApplicationController
def index
@user = User.find(params[:id])
end
# GET /profile/

Using ActiveRecord and Mongoid Together

To start things off, you want to get some kind of ActiveRecord gem (i.e. SQLite3, MySQL2, Postgres 'pg') and manually create your database.yml.

Here is a snippet from Postgres:

# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
#   gem install pg

On OS X with Homebrew:

require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do