2013-03-05 135 views
0

我已经在控制器中执行以下代码传PARAMS的方法哈希在轨

def show 

    client = GameAccounts::GameAccountsClient.new 

    .. 

    json = client.get_accounts(..) 
    .. 
    end 

我在GameAccountsClient下面的代码

def get_accounts(..) 
     response = query_account(CGI.escape(params[:name]) 
     JSON.parse(response.body) 
    end 

我上面的代码,我不知道如何在调用控制器中的get_accounts方法时传递params [:name]。任何人都可以帮我把散列的方法传给rails吗? 。谢谢

回答

0

如果我理解正确,你只需要通过params[:name]到你的模型方法。

def show 
    client = GameAccounts::GameAccountsClient.new 
    json = client.get_accounts(params[:name]) 
end 

def get_accounts(name) 
    response = query_account(CGI.escape(name) 
    JSON.parse(response.body) 
end