Tag: Ruby

Connect MS SQL Server with Rails

To connect MS SQL Server with Ruby on Rails follow the below steps: SQL Server (2005 or higher recommended) Install the adapters and driver [code] gem install tiny_tds gem install activerecord-sqlserver-adapter [/code] Ensure the activerecord adapter and db driver gems are defined in your Gemfile [code] gem ‘tiny_tds’ gem ‘activerecord-sqlserver-adapter’ [/code]

Permanent link to this article: https://blog.openshell.in/2013/04/connect-ms-sql-server-with-rails/

Unable to create rails application with sqlserver

Could not find “config/databases/sqlserver.yml” in any of your source paths. Your current source paths are: $HOME/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/generators/rails/app/templates Error: Template sqlserver.yml file missing. Solution: Need to update sqlserver.yml file in the specific location to fix this issue. Step1: Download sqlserver.yml configuration file. Step2: Extract the downloaded zip file. Step3: Copy extracted sqlserver.yml configuration file into the location which …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/04/unable-to-create-rails-application-with-sqlserver/

Disable foreign key checks in MySQL

Disabling foreign key checks in MySQL is usefull when you are dealing with tables that use foreign keys (InnoDB engine). You can not delete (drop) multiple tables, a parent table or a child table until you disable foreign key checks four your current database. The sql command to disable foreign key checks is: [sql]SET FOREIGN_KEY_CHECKS …

Continue reading

Permanent link to this article: https://blog.openshell.in/2012/09/disable-foreign-key-checks-in-mysql/

Try Catch Finally block in Ruby

This the ruby code which is equivalent of a try/catch/finally block in other languages. #Try catch block Syntax begin somecode() rescue puts “Error #{$!}” ensure this_code_will_execute_always() end # Sample Code f = File.open(“testfile.txt”) begin # .. process rescue # .. handle error else puts “– no errors!” ensure f.close unless f.nil? end

Permanent link to this article: https://blog.openshell.in/2011/03/try-catch-finally-block-in-ruby/

REST methods form request in Ruby On Rails Client

In order to access RESTful web services from Ruby Client script using form request. The method net/http tries to connect over HTTP even of the uri is HTTPS. For HTTPS, You need to explicitly tell net/http that a secure connection should be used. REST client code as shown below: # Basic REST. # Most REST …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/03/rest-methods-form-request-in-ruby-on-rails-client/

HTML mailto attribute

The HTML mailto is a quick way to add the facility of receiving feedback from visitor on the web site. when the visitor clicked the HTML mailto, It lanuches their email program with new email window. Note: HTML mailto assumes that the visitor has configured an email client (Outlook Express, Netscape Messenger, Thunderbird or any …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/html-mailto-attribute/

Tips to inspect the code in Rails

Inspect It inspects the value. It formats the array with square brace, hash with curly braces with arrows between the key value pairs inspecting parameter. Type It identifying the type of the instance variable. Debug It give nice, easy to read inspection of the value and displayed in a formatted way. These are all some …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/tips-to-inspect-the-code-in-rails/

Ruby Symbols Description

Matter related to the old and new Ruby programmer, and Ruby’s symbols are confusing sometimes or always. Smoothly before this, can not get used is pretty. People learn about the Ruby language is often Rubionreiruzu learn from the project. The Rubionreiruzu symbol is everywhere. There really is everywhere. So, pay attention to the concept of …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/ruby-symbols-description/

Debugging Rails

You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that “tail –f” commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/debugging-rails/

Finders are great but be careful

Finders are very pleasant to use, enable you to write readable code and they don’t require in-depth SQL knowledge. But the nice high level abstraction come with a computational cost. Follow these rules of thumb: Retrieve only the information that you need. A lot of execution time can be wasted by running selects for data …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/finders-are-great-but-be-careful/