Posts

Showing posts from October, 2015

How to pass hash in Postman

By the looks of what you are trying to send, you need to change the Grape restriction, because destinations is an Array , not a Hash : requires : destinations , type : Array   You don't need the "destination" hash when sending the request: { destinations => [ { name => 'dest1' , other_attribute : 'value' , etc ... }, { name => 'dest2' , other_attribute : 'value' , etc ... }, { name => 'dest3' , other_attribute : 'value' , etc ... } ]}   This creates an Array of hashes. In order to send this through POSTMAN, you'll need to modify that destinations param your sending and add multiple lines in POSTMAN. Something like: destinations [][ name ] 'dest1' destinations [][ other_attribute ] 'value1' destinations [][ name ] 'dest2' destinations [][ other_attribute ] 'value2'

message system in ruby on rails

1- Create message model:-  rails g model message sender_id:integer recepient_id:integer body:text 2- Define Assosciation and scopes:-  class Message < ActiveRecord::Base     belongs_to :sender,      :class_name => 'User',      :foreign_key => 'sender_id'     belongs_to :recepient,      :class_name => 'User',      :foreign_key => 'recepient_id'     scope :conversations, lambda{|sender_id,recepient_id| where('sender_id = ? AND recepient_id = ? ',sender_id, recepient_id ).order("created_at DESC")}     scope :friends_conversations, lambda{|recepient_id,sender_id| where('sender_id = ? AND recepient_id = ? ',sender_id, recepient_id ).order("created_at DESC")} end 3- User model:- class User < ActiveRecord::Base  has_many :received_messages,  :class_name => 'Message',  :foreign_key => 'recepient_id'  has_many :sent_messages,  :class_name => 'Message'

UBUNTU Wi-Fi hotspot is not detected by android phone

Image
Share Internet Connection With Android in Ubuntu 14.04 June 8, 2014 —  127 Comments This quick tip is going to show you how to create wifi hotspot in Ubuntu 14.04 so that you can share a wired internet connection with Android devices through your wireless card. I’ve written about this in another post using a third-party app called ap-hotspot , but some readers said that not work. The pre-installed Network Manager in Ubuntu Unity does not support Access Point (AP) mode which is required for Android devices. Fortunately, KDE’s connection editor support this mode, below is how: NOTE: To do below steps, your Wireless Card must support Access Point (AP) mode. 1. Click the link below to bring up Ubuntu Software Center and click install kde-nm-connection-editor: Click Install KDE’s Network Manager 2. Once installed, press Alt+F2 and run command to launch the app: kde-nm-connection-editor 3. Cli

import data from csv to postgresql

sudo -u postgres psql   Postgresql to csv file:-   COPY products TO '/home/products.csv' DELIMITER ',' CSV HEADER ; CSV to Postgresql table:-   COPY products FROM '/home/products.csv' DELIMITER ',' CSV HEADER ;   products is table name.