To create a form dynamically using JavaScript on fly of the webpage. This which helps to create form and input controls dynamically. [javascript] /* To create form with javascript */ var form = document.createElement("form"); form.setAttribute(‘method’,"post"); // form method form.setAttribute(‘action’,"test.php"); // form action url form.setAttribute(‘name’,"frmName"); // form name form.setAttribute(‘id’,"frmId"); // form ID form.setAttribute(‘target’,"_blank"); // form target …
Tag: ROR
Permanent link to this article: https://blog.openshell.in/2013/12/dynamically-create-form-in-javascript-on-fly/
Oct 18
How to retrieve the last record in each group using mysql
In single SQL query itself we can retrieve the last record in each group. It will help us to perform action better, faster and simpler. In this post I will explain about you how to do it. Here is my table structure for your reference. [sql] desc post_status; +—————-+————-+——+—–+———+—————-+ | Field | Type | Null …
Permanent link to this article: https://blog.openshell.in/2013/10/how-to-retrieve-the-last-record-in-each-group-using-mysql/
Aug 04
MySQL Error – SQL_BIG_SELECTS
While executing JOIN SQL query in live server, i got the following error. [code] The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay: [/code] To resolve this error, I have used the following SQL query before executing the JOIN SQL query. …
Permanent link to this article: https://blog.openshell.in/2013/08/mysql-error-sql_big_selects/
Apr 10
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/
Apr 10
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 …
Permanent link to this article: https://blog.openshell.in/2013/04/unable-to-create-rails-application-with-sqlserver/
Mar 17
mysql2 gem for windows error
By installing Development Kit and MySql Connector: To install Development Kit: 1. Left double-click the self-extracting executable (SFX) to install the DevKit artifacts into. For example, C:DevKit. 2. cd <DEVKIT_INSTALL_DIR> 3. ruby dk.rb init to generate the config.yml. Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at …
Permanent link to this article: https://blog.openshell.in/2013/03/mysql2-gem-for-windows-error/
Sep 22
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 …
Permanent link to this article: https://blog.openshell.in/2012/09/disable-foreign-key-checks-in-mysql/
Mar 17
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/
Mar 17
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 …
Permanent link to this article: https://blog.openshell.in/2011/03/rest-methods-form-request-in-ruby-on-rails-client/
Jan 28
Random Image Rotation in ROR
It’s pretty easy to accomplish random image rotation in ROR. This is a simple example of how it can be done, and of course there are ways to make it better (for example, this snippet will only rotate and display .jpg, .gif, and .png files). First, create a folder – let’s name it “rotate” – …
Permanent link to this article: https://blog.openshell.in/2011/01/random-image-rotation-in-ror/