You can add the username and password to the URL string,
username = 'me'
password = '12345'
response = RestClient.post "http://#{username}:#{password}@localhost:3000/api/rules",
:books => {:book_name => "Harry Porter", :author => "JR"}
Or you can pass them in a hash like this,
resource = RestClient::Resource.new('http://localhost:3000/api/rules', :user => 'me', :password => '12345')
response = resource.post(:books => {:book_name => "Harry Porter", :author => "JR"})