我想在我的rails应用程序中实现音轨

时间:2013-01-22 10:00:33

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 soundcloud

嘿,我就像我的rails应用程序这样的tuotorial https://github.com/soundcloudlabs/connect-with-soundcloud-rails-demo 还有一段视频http://www.youtube.com/watch?v=oSBfGV0uUA4我看了这个并按照它的教导实施了这一点。但我得到错误

ArgumentError in SoundcloudController#connected

wrong number of arguments (0 for 1)

Rails.root: /home/prem/Desktop/souncloud/connect-with-soundcloud-rails-demo
Application Trace | Framework Trace | Full Trace

app/controllers/soundcloud_controller.rb:9:in `connected'

Request

Parameters:

{"code"=>"12c142cb2626b9c314ea25af87cbad48",
 "signed_up"=>"0"}

Show session dump

Show env dump
Response

Headers:

None

有什么想法可以解决这个问题吗? 我的声音云控制器是这样的

class SoundcloudController < ApplicationController
  def connect
    redirect_to soundcloud_client.authorize_url(:display => "popup")
  end

  def connected
    if params[:error].nil?
      soundcloud_client.exchange_token(:code => params[:code])
      me = soundcloud_client.get("/me")

      login_as User.find_or_create_by_soundcloud_user_id({
        :soundcloud_user_id  => me.id,
        :soundcloud_username => me.username
      })

      current_user.update_attributes!({
        :soundcloud_access_token  => soundcloud_client.access_token,
        :soundcloud_refresh_token => soundcloud_client.refresh_token,
        :soundcloud_expires_at    => soundcloud_client.expires_at,
      })
    end
    render :layout => false
  end

  def disconnect
    login_as nil
    redirect_to root_path
  end

private

  def soundcloud_client
    return @soundcloud_client if @soundcloud_client
    @soundcloud_client = User.soundcloud_client(:redirect_uri  => soundcloud_connected_url)
  end


end

1 个答案:

答案 0 :(得分:1)

如果您的代码与github上的代码相同,则问题出在第9行

me = soundcloud_client.get('/me')

也许你有soundcloud_client.get之类的东西?您能否显示SoundCloud控制器文件的代码并检查此行是否正确