Rails easyist way to create hash with certain attributes and also nested
In my controller I have:

      def search
      @sog = Konkurrencer.where("titel like ?", "%#{params[:q]}%")
      @kate = []
      @sog.each do |kat|
        h = {}
        kat.attributes.each{|k,v| h[k] = v.respond_to?(:force_encoding) ? v.dup.force_encoding("UTF-8") : v }
        @kate << h
      end
      respond_to do |format|
      format.html
      format.json { render :json => @kate }
      end

The problem is that the JSON contains all the attributes for the model. How do I create a JSON that have only ID, url and titel?

The JSON should also contain the key "url" which key should be the URL for the associated photo. I use paperclip. The path is: `@konkurrencer.photo.image.url`
Rails easyist way to create hash with certain attributes and also nested
===

In my controller I have:

      def search
      @sog = Konkurrencer.where("titel like ?", "%#{params[:q]}%")
      @kate = []
      @sog.each do |kat|
        h = {}
        kat.attributes.each{|k,v| h[k] = v.respond_to?(:force_encoding) ? v.dup.force_encoding("UTF-8") : v }
        @kate << h
      end
      respond_to do |format|
      format.html
      format.json { render :json => @kate }
      end

The problem is that the JSON contains all the attributes for the model. How do I create a JSON that have only ID, url and titel?

The JSON should also contain the key "url" which key should be the URL for the associated photo. I use paperclip. The path is: `@konkurrencer.photo.image.url`