GitHub now enforces the User Agent. If you do API calls without user agent you will get a 403 error message back. Check out this post: http://developer.github.com/changes/2013-04-24-user-agent-required/. If you are using the HTTParty GEM in Ruby to do the API calls you have to set the headers. Here an example:
At the last DevCamp in KA I had some good discussion about the VersionEye API. That’s why I enhanced it a little bit. I just introduced a new attribute to the project dependencies. The “stable” attribute. If this is true than that means that the newest version is stable, otherwise the newest version is unstable.Continue reading “VersionEye API : Dependency stable”
This code checks if the given link exists and returns an HTTP Code 200.
It is possible to remove 1 single document from an existing ElasticSearch Index! I am using the Ruby GEM Tire to deal with the ElasticSearch Server. This is the command to delete an existing document: Tire.index( <INDEX_NAME> ).remove( <DOCUMENT_TYPE> , DOCUMENT_ID ) Worked fine for me 🙂
Parsing is CSV file in Ruby is very easy. Check out this code: require “csv” csv_file_path = “ABSOLUTE_PATH_TO_YOUR_CSV_FILE” file = File.open(csv_file_path, “r:ISO-8859-1”) csv = CSV.parse file That’s it. This is how you get the first row: csv.first This is how you get the first column of the first row: csv.first.first And this is how youContinue reading “Parsing a CSV in Ruby”
Not for my self. How to check quickly the response code of an URL request in Ruby? Net::HTTP.get_response(URI.parse(“http://localhost:3000/my_fancy_resource.html”)).code == 200
Through the new VersionEye API you can get a list of all licenses for your software project. VersionEye now supports 7 different package managers. In this example I will use a Ruby Gemfile to demonstrate how easy it is to get the license list. First of all you need to signup at VersionEye to get yourContinue reading “How to get a list of all licenses for your Software Project”
CloudControl is a pretty cool StartUp from Berlin. It is a PaaS Solution like Heroku. CloudControl is hosting on AWS in Ireland. They are more flexible than Heroku. Beside the number of web processes you can choose how much RAM each instance should have. This is a cool features what you don’t get on Heroku.Continue reading “Ruby on Rails + MySQL on CloudControl”
In a regular project you are using a handfull Software Libraries. Every Library in your project can use a different license. To get a list of all licenses which are used in your project can be difficult. You can double check the license for every single library in your project manually. But that is timeContinue reading “Getting a list of all Licenses in a Project”
Capistrano is a ruby based deployment tool which executes commands in parallel on multiple remote machines, via the SSH protocol. With Capistrano you can deploy your application on N server with one single command from your dev machine. You don’t need to login via SSH to your server. If you don’t deploy your app onContinue reading “Capistrano + Rails + Unicorn + NGinx + RVM”
This is a tutorial how to use ElasticSearch with Ruby on Rails. ElasticSearch is a distributed RESTful Search Engine build on top of Apache Lucene. Sure! You can use your SQL database for search. But that is usually slow and you will not get very good search results. With ElasticSearch you can deliver a fuzzyContinue reading “Ruby on Rails + ElasticSearch”
I tried to install the native pg gem on Mac OS X Mountain Lion (10.8.2): gem install pg and got this exception: Building native extensions. This could take a while… ERROR: Error installing pg: ERROR: Failed to build gem native extension. /Users/robertreiz/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb checking for pg_config… yes Using config values from /usr/bin/pg_config checking for libpq-fe.h…Continue reading “Installing native pg gem on Mountain Lion”
In a Rails application you can you this tasks on localhost to reset the database. rake db:drop rake db:create rake db:migrate And that will delete the db schema, create a new one and run all migrations to create the tables. This is awesome! But if try to run this on heroku: heroku run rake db:dropContinue reading “Reset Postgres DB on Heroku”
Today I did a “git push heroku master” do deploy an application. And than suddenly I got a big exception and the build failed. The funny thing is that CSS is the root of the problem. This CSS line here broke the deployment: height: inherit important!; Indeed it should be: height: inherit !important; Heroku is very sensible 🙂
ActiveRecord is my favorite way to access a SQL database. It offers very useful validation inside of a model. But sometimes you just want to save an attribute quickly, without validating the whole object. For that you can pass a parameter to the save method. object.save(:validate => false) That saved me a lot of time. Awesome!
Not for me. The 3 most important Rake commands in a Ruby on Rails application are: rake db:drop rake db:create rake db:migrate First command drops the database. Second command creates the database. Third command runs all migrations and creates basically the schema. This is incredible useful.
by executing this command: rails generate rspec:install I got this error message. ~.rvm/gems/ruby-1.9.3-p194@ms/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in `method_missing’: undefined local variable or method `consultant_id’ for #<Class:0x007fdb93a08bd0> (NameError) the problem was that in one of the models I used :through => consultant_id As soon I resolved this option it worked. Strange!
I just tried to run “rspec” and got this error. ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: cannot load such file — spec_helper (LoadError) The problem was that the file “spec_helper” was not existing. a simple: rails generate rspec:install solved the problem.
I just created a rails migration for one of my tables. Wanted to change the type of a column from string to integer. My migration looked like that: Unfortunately it didn’t worked out. I got this Exception: PG::Error: ERROR: column “title_id” cannot be cast to type integer : ALTER TABLE “consultants” ALTER COLUMN “title_id” TYPEContinue reading “Rails Migration column_change”
By default there is no seamless deployment on Heroku. That means, if you do a git push, your app gets deployed and there is a little downtime. That’s just because how Heroku works. At first they kill your running dynos, then they build the new app, deploy it on new dynos and finally boot upContinue reading “Seamless Deployment with Heroku”