I am trying to get the IP address and send it to my rails server as a parameter of a POST request. Is this action safe?
There's no utility on sending IP address of local device, on which you app is running. There're good chances that you'll get only local ip-address from the device, which is hardly useful. Moreover, in the days of dynamic public IP address assignment from ISPs, IP addresses are hardly used for monitoring or tracking purpose(As there're good chances that public IP address assigned to you by your ISP, may be assigned to some other computer, at another time).
To ensure that the data is 'safely' POSTed to your server such that it remains confidential and is not tampered with by an attacker in transit, use transport layer security (TLS).
To ensure that your application 'safely' processes the POSTed data, validate that data prior to use to ensure it is what you expect to receive i.e an IP Address.