SL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed


Make sure your application root config/initializer has omniauth file. 
RAILS_ROOT/config/initializers/omniauth.rb if yes double check is 
this file contain following code.

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, 'APP_ID', 'APP_SECRET'
end
If you have still same issues, U need to modify above code again,

If your app  running on linux OS add this code
Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, APP_ID, APP_SECRET, {:client_options => \
   {:ssl => {:ca_file => "/usr/lib/ssl/certs/ca-certificates.crt"}}}
end

If your app  running on window OS add this code

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET,\
   {:client_options => {:ssl => {:verify => false}}}
end

Now your application should run, if still problem. Start your server...
Advertisements

haml


I am going to create a quick-start demo which would be helpful to  guide how to get an application set up with HAML.

App setup:

Rails 3.1, Mongodb,haml

1. rails new test_haml --skip active-record

will create a new app “test_haml” and skip active record libraries since i am using Mondodb so i will use mongoid.

2.Include some gems in gemfile.

gem ‘mongoid’, ‘2.0.0.beta.19’
gem ‘bson_ext’
gem “haml”

3. Now our’s next command will be

bundle install

because we need to update app with latest gem added in gemfile. Once the gems have installed we’ll need to run the Mongoid configuration generator so that it can create the configuration YAML file.

 
4.rails g mongoid:config

that will generate file mongoid.yaml some like
efaults: &defaults
host: localhost
# slaves:
#   – host: slave1.local
#     port: 27018
#   – host: slave2.local
#     port: 27019development:
<<: *defaults
database: test_haml_developmenttest:
<<: *defaults
database: test_haml_test

# set these environment variables on your prod server
production:
host: <%= ENV[‘MONGOID_HOST’] %>
port: <%= ENV[‘MONGOID_PORT’] %>
username: <%= ENV[‘MONGOID_USERNAME’] %>
password: <%= ENV[‘MONGOID_PASSWORD’] %>
database: <%= ENV[‘MONGOID_DATABASE’] %>

5.git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml

This will configure Rails 3 to use HAML generators instead of ERB  when we run any sacffold or controller because it is annoying to constantly remove .erb files, and or edit them into HAML syntax.

6. Finally we have need a small configuration setup that will assist in haml file generation.

we will add this bit of code in config/application.rb after "config.filter_parameteres +=[:password]" 
config.generators do |g|   g.template_engine :haml  end We completed with all setup, now need to run a sacffold and let's see how is working!!!!!!!!!!!!!!!!! 

7.rails generate scaffold Contacts name:string phone:string

8. rais server

take a look in view folder, you find all file in haml extention.

Enjoyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy


			

rake aborted! You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Consider using bundle exec.


rake aborted!
You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Consider using bundle exec.

(See full trace by running task with –trace)

Solution:

1. Include below rake version in your gemfile

“gem ‘rake’, ‘0.9.2’ ”

2. Open rake file and include below line above ==>require ‘rake’

require ‘rake/dsl_definition’

3.In same rake file add below code above ==>app_name::Application.load_tasks

module ::app_name
class Application
include Rake::DSL
end
end

module ::RakeFileUtils
extend Rake::FileUtilsExt
end

make sure app_name will be your application name, just copy  app_name from ” app_name::Application.load_tasks”

Mongodb queries


Here is the some important frequently used mongodb queries.

After running mongodb server(mongod) and  interactive shell(mongo),  Our’s first command should be

1. help

->Which will show a lot  of useful command that is helpful at any instance working with mongodb.

2.db.help();

->It is database level help command that will show some of data level command.

3. db.help;

-> This command will show database level methods.

All above command is basic mongodb command.

How to create database?

1. use databasename;

In my case it is “use mongotest”,  here USE  is command to create database and  mongotest is database name. It is one of the nice feature of mongodb if there will be no database with this particular name, will create new database else use(move) to exiting database.

 Create table!!!!!!!

1. db.tablename.save({“name”:”ankit”,”phone”:”09533667506″});

Fetch data from tables!!!!!!!!!!

1. db.tablename.find();

return data of table.

2.db.tablename.find;

return methods it self.

Create another record!!!!!!!!!

x={“name”:”abhay”,”phone”:”09932329856″}

db.contacts.save(x);

this is another way of creating new record and saving as an object.

Fetch particular record from tables !!!!!!!!!!

db.contacts.find({“name”:”ankit”});

N.T. -> Search option is case sensetive.

find record using id

> db.contacts.find({_id:ObjectId("4ea3aa28eaaf3871b0549dfa")});
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506" }

Update particular record into tables !!!!!!!!!!

-> there is two way to update table

1. Using save()->this is one of nice feature to mongodb, if there will already row in table it will update with new attribute else will create new record.

2. Using update()->will only update exiting record.

find record using object

> x = db.contacts.findOne({"name":"ankit"});
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506"
}
Now we have object x with reference of contacts table.
> x
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506"
}

Now i am going to add new attribute email

> x.email = "ankit@gmail.com"
ankit@gmail.com
Let's see updated row 
> x
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506",
        "email" : "ankit@gmail.com"
}

Now we fetch details from table

> db.contacts.find();
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506" }
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"),
 "name" : "abhay", "phone" : "9932326589" }

table is not updated here, we need to update table.

> db.contacts.save(x);
Now try again
> db.contacts.find();
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"), 
"name" : "abhay", "phone" : "9932326589" }
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506",
 "email" : "ankit@gmail.com" }

Delete particular record from tables !!!!!!!!!!

> db.contacts.remove(x);
let's see row is there or not
> db.contacts.find();
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"),
 "name" : "abhay", "phone" : "9932326589" }
yah, this row is deleted
THAT ALL WAS THE CRUD OPERATION ON MONGODB TABLE.