0
  def show
    email = UserEmail.find_by_key(UserEmail.key_for(UserEmail.new(:publisher_id => @publisher.name, :app_id => @app ? @app.name : 'none', :external_uid => @user.external_uid)))
    respond_to do |format|
      format.xml { render :xml => @user.to_xml(:session => false, :authorized => user_logged_in? || publisher_logged_in? || app_logged_in?, :publisher => @publisher, :email => email || false) }
      format.json { render :json => @user.to_json(:session => false, :authorized => user_logged_in? || publisher_logged_in? || app_logged_in?, :publisher => @publisher, :email => email || false) }
    end
  end

这是我的代码,我特别想了解以下内容:

format.json { render :json => @user.to_json(:session => false, :authorized => user_logged_in? || publisher_logged_in? || app_logged_in?, :publisher => @publisher, :email => email || false) }
4

1 回答 1

0

唯一to_json可以理解的参数是:only:except:methods(请查看此处:include的文档)。

如果您to_json使用其他参数,那是因为它(或方法as_json)已在您的模型中被覆盖。

于 2013-02-27T11:01:33.523 回答