Saturday, 18 August 2012

How to activate DBMS_output in Rails

I have added some debug statements in my sql Procedure and I want to see the dbms output content in my test log file
DBMS_OUTPUT.PUT_LINE ('Hello!!!');
I open the console
ruby script/console test
check the enable_dbms_output field is true or not By running the command
ActiveRecord::Base.connection
If it is not true then reset to true by running below command before your testcase.
ActiveRecord::Base.connection.enable_dbms_output
then you can see the dbms_output statements in test.log file.

Rails : Alert message with new line

I was passing the error message by joining each error message with \n and in alert I am getting all error message with \n text instead of new line, below is the code which am passing the message
@product.errors.full_messages.join('\n')
and I am getting something like below Name can't be blank \n Address can't be blank After doing search in google some how I got that I have to give \n in double quote like below
@product.errors.full_messages.join("\n")
and it works..

Rails: Invalid character \240 (syntax error)

I got this error when I copied text from notepad(clipboard) and paste it in Linux server. Some times If you copy some text from notepad and paste it in server you will not notice some Ascii character will be pasted which is not seen better you have to type content instead of copy it from notepad.

Monday, 13 August 2012

Devise Couldn't find User with id=sign_in

I have added routes for devise and users in this manner
AppName::Application.routes.draw do resources :users devise_for :users
and i am getting error like"Couldn't find User with id=sign_in" while trying to login application. I changed the order in routes.rb file then it works
AppName::Application.routes.draw do devise_for :users resources :users

Saturday, 11 August 2012

Rails Migration Datatypes and DDL Methods

Rails DDL Methods
  • add_column
  • remove_column
  • change_column
  • rename_column
  • create_table
  • drop_table
  • change_table
  • add_index
  • remove_index
Data Types for migration
  • binary
  • boolean
  • primary_key
  • date
  • datetime
  • time
  • timestamp
  • integer
  • decimal
  • float
  • string
  • text
for more information click