Q: Render JSON array of strings from one DB column I've researched other JSON rendering issues here, but I haven't found any that are looking to end up with an array. I found many posts about rendering as hash, but they haven't been helpful.
Recent attempts include:
def create
  params[:_json].each do |ip|
    IpAddress.create(ip: ip)
  end

  ips = IpAddress.pluck(:ip)

  ips.each do |ips|
    ips.to_s
  end

  render json: ips
end

As well as
def create
  params[:_json].each do |ip|
    IpAddress.create(ip: ip)
  end
  render json: IpAddress.all, methods: [:ip]     
end

Both of these attempts return the entire array of database rows.
Any help is appreciated. Thanks!

A: This should work in general.
Just building the array up while creating the database entries and then return it.
def create
  ips = params[:_json].inject([]) do |a, ip|
    a << IpAddress.create!(ip: ip).ip
    a
  end
  render json: {ips: ips}
end


A: Sorry, my def create action was a non-issue. It was rendering properly, but the problem was that my test was failing because after creating, it was hitting the index action to see if the array was saved properly. So, I added 
  def index
    render json: IpAddress.pluck(:ip)
  end

And my test passed.
Thanks for the help.
