Monthly Archives: July 2012

REST show action :- using other field data

show action use primary key “id” for displaying a particular record. if want to use other filed data as the link /welcomes/john ( where welcomes is the controller and john is the value in the name field ) In the … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

Polymorphic Associations in rails

  Refer above figure and tables products,employees and pictures With polymorphic associations, a model can belong to more than one other model, on a single association 1) In Picture model want to mention as follows class Picture < ActiveRecord::Base belongs_to … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

The has_one :through Association in rails

  Refer above figure and the tables suppliers,accounts,account_histories A has_one :through association sets up a one-to-one connection with another model. 1) In Supplier model want to mention as follows class Supplier < ActiveRecord::Base has_one :account has_one :account_history, :through => :account … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

has_many :through association in rails

  Refer above figure and the tables physicians, patients and appointments. This association is often used to set up a many-to-many connection with another model. 1) In Physician model want to mention as follows class Physician < ActiveRecord::Base has_many :appointments … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

Error installing sqlite3- Failed to build gem native extension in debian.

Solution:- install – libsqlite3-dev   http://www.klairvoyant.in  

Posted in rails, ROR, ruby on rails, web development | Tagged , , | Leave a comment

Many to many relationships in rails

Refer above figure and the tables   “books” and “stores” In a many to many relationship each side can point to more than one related data.A store contains many books and many books will be in a store. a many to … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , | Leave a comment

Many to one relationships

Refer above figure and tables books and chapters Here one book contains many chapters ( one to many) For this rails requires  a foreign key and it goes to the table chapters while code 1) Foreign keys in Rails should … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

One to one relation in rails

Refer above figure books and cover_images tables assumes that same image is never used on two different covers. there is always a one-to-one relationship between books and cover images. For this rails requires  a foreign key.Foreign key goes to the … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , , , | Leave a comment

Error installing mysql2: Failed to build gem native extension – in debian

solved by installing the following sudo apt-get install libmysql-ruby libmysqlclient-dev   http://www.klairvoyant.in  

Posted in rails, ROR, ruby on rails, web development | Tagged , | Leave a comment

using different field as primary key instead of default primary key in rails

1) while creating table (migration file)  mention “id as false”  as follows class CreateRadusergroups < ActiveRecord::Migration def change create_table :radusergroups, :id => false do |t| t.integer :priority t.integer :image_id t.string :username, :groupname end end end 2) setting another primary key … Continue reading

Posted in rails, ROR, ruby on rails, web development | Tagged , | Leave a comment