xmlruby-on-rails-3jsonviewhobo

Is it possible to render a view in XML or JSON using ruby


Rendering a JSON or XML view in rails 3 is straight forward enough. As Hobo does not use views, I cannot work out how to do the same in a hobo project and the docs are not very illuminating. Has anyone done this?

I am using rails 3.0.3 and hobo 1.3.0 pre29


Solution

  • The right solution is:

    def show
        hobo_show do |expects|
          expects.json { render :json => @user.to_json }
          expects.html { hobo_show }
        end
    end
    

    for index:

    def index
        hobo_index do |expects|
          expects.json { render :json => @users.to_json }
          expects.html { hobo_index }
        end
    end