小编pat*_*kil的帖子

Postgresql表存在,但在查询时得到"关系不存在"

我有一个带有许多表的postgresql数据库.如果我查询:

SELECT column_name
FROM information_schema.columns
WHERE table_name="my_table";
Run Code Online (Sandbox Code Playgroud)

我将获得正确返回的列的列表.

但是,当我查询时:

SELECT *
FROM "my_table";
Run Code Online (Sandbox Code Playgroud)

我收到错误:

(ProgrammingError) relation "my_table" does not exist
'SELECT *\n    FROM "my_table"\n' {}
Run Code Online (Sandbox Code Playgroud)

有关为什么我可以获取列,但无法查询表的任何想法?目标是能够查询表.

sql postgresql

55
推荐指数
5
解决办法
12万
查看次数

iOS代理没有被设置并返回nil(Swift)

当我尝试设置委托时,我得到nil,并且无法弄清楚为什么委托没有正确设置.

我有一个视图控制器ListViewController,我添加了一个子视图,musicPlayer.musicPlayer是一个UIView,它有一些按钮,可以在ListViewController点击时触发动作.

musicPlayer 设置如下:

protocol MusicPlayerControlsDelegate {
    func playPauseClicked()
}


class musicPlayer: UIView {

var myDelegate: MusicPlayerControlsDelegate?

//this should trigger function in delegate
@IBAction func playOrPause(sender: AnyObject) {    
    println(myDelegate?)
    myDelegate?.playPauseClicked()        
}
Run Code Online (Sandbox Code Playgroud)

ListViewController 设置如下:

class ListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, MusicPlayerControlsDelegate {

var musicControls:musicPlayer = musicPlayer()

override func viewDidLoad() {
    musicControls.myDelegate = self
}

//adds musicPlayer nib as a subview to ListViewController
@IBAction func playInApp(sender: AnyObject) {

    let bundle = NSBundle(forClass: musicPlayer.self)
    var playerSubview …
Run Code Online (Sandbox Code Playgroud)

ios swift

6
推荐指数
2
解决办法
9363
查看次数

"virtualenv与此系统或可执行文件不兼容"使用虚拟环境和anaconda

我正在尝试使用virtualenv启动虚拟环境,我收到此错误:

Already using interpreter /Users/pkilcrease/anaconda/bin/python3
Using base prefix '/Users/pkilcrease/anaconda'
New python executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python3
Also creating executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python
ERROR: The executable /Users/pkilcrease/.virtualenvs/bodega/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/pkilcrease/.virtualenvs' (should be '/Users/pkilcrease/.virtualenvs/bodega')
ERROR: virtualenv is not compatible with this system or executable
Run Code Online (Sandbox Code Playgroud)

我正在运行的命令是 mkvirtualenv -a . --no-site-packages --python='which python3' -r requirements.txt bodega

我的.bashrc文件目前看起来像这样:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/Users/pkilcrease/anaconda/bin/virtualenvwrapper.sh
source /Users/pkilcrease/anaconda/bin/virtualenvwrapper_lazy.sh
Run Code Online (Sandbox Code Playgroud)

我觉得anaconda和virtualenv存在一些问题,导致这里的问题,但不知道如何解决这个问题,或者它是否只是一个红鲱鱼.

python virtualenv anaconda

6
推荐指数
1
解决办法
2039
查看次数

刷新令牌时Spotify Web API错误请求错误"invalid_client"

我正在使用Spotify Web API在Rails中构建应用程序.我构建了一个刷新用户令牌的方法,但收到400错误.根据Spotify Web API文档,我的请求标题需要采用以下格式:

Authorization: Basic <base64 encoded client_id:client_secret>
Run Code Online (Sandbox Code Playgroud)

使用Httparty gem,这是刷新访问令牌的POST方法:

def refresh_token
client_id = "foo"
client_secret = "bar"
client_id_and_secret = Base64.encode64("#{client_id}:#{client_secret}")
result = HTTParty.post(
    "https://accounts.spotify.com/api/token",
    :body => {:grant_type => "refresh_token",
              :refresh_token => "#{self.oauth_refresh_token}"},
    :headers => {"Authorization" => "Basic #{client_id_and_secret}"}
    )
end
Run Code Online (Sandbox Code Playgroud)

以下是"结果"最终结果:

=> #<HTTParty::Response:0x7f92190b2978 parsed_response={"error"=>"invalid_client", "error_description"=>"Invalid client secret"}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"server"=>["nginx"], "date"=>["Sun, 31 Aug 2014 22:28:38 GMT"], "content-type"=>["application/json"], "content-length"=>["70"], "connection"=>["close"]}>
Run Code Online (Sandbox Code Playgroud)

我可以解码client_id_and_secret并返回"foo:bar",所以我不知道为什么我收到400错误.任何见解都非常感谢.

ruby-on-rails spotify httparty

3
推荐指数
1
解决办法
2671
查看次数

Rails form_for提交按钮什么都不做

我敢肯定,我只是在这里错过了一些简单的东西,但不能为我的生活弄明白什么.

我有一个表单,我更新模型的属性.

            <%= form_for @gf do |f| %>
                    <div class="form-field">
                        <%= f.text_field :first_name, :placeholder => "First Name" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :last_name, :placeholder => "Last Name" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :address_line_one, :placeholder => "Address" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :address_line_two, :placeholder => "Address (second line)" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :city, :placeholder => "City" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :state, :placeholder => "State" %>
                    </div>
                    <div class="form-field">
                        <%= f.text_field :zip_code, :placeholder => "Zip …
Run Code Online (Sandbox Code Playgroud)

forms ruby-on-rails

1
推荐指数
1
解决办法
3516
查看次数