小编Mar*_*lmi的帖子

使用Paperclip删除图像

我正在使用Paperclip在我的Rails应用程序中保存图片:

用户模型:

class User < ActiveRecord::Base
  has_one :profile
end
Run Code Online (Sandbox Code Playgroud)

档案型号:

class Profile < ActiveRecord::Base
  has_attached_file :avatar, :styles => {:medium => "300x300>", :thumb => "100x100>"}
  belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)

我尝试删除头像:

current_user.profile.avatar = nil
current_user.profile.save
Run Code Online (Sandbox Code Playgroud)

但它不起作用.可能吗?

file-upload ruby-on-rails paperclip

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

Facebook登录Ruby on Rails应用程序

我正在使用带有JavaScript的Facebook flogin按钮开发Ruby on Rails应用程序.

我的代码:*

<fb:login-button perms="email" onlogin="createFbSession();"></fb:login-button>

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>

<script>
    FB.init({
        appId:"xxxxxxx", cookie:true,
        status:true, xfbml:true
    });
    function createFbSession() {
        FB.getLoginStatus(function(response) {
            if (response.session) {
                window.location = "<%= fb_login_path %>";
            }
        });
    }
</script>
Run Code Online (Sandbox Code Playgroud)

当我点击flogin按钮时,有时我会在弹出窗口中收到以下错误:

发生错误.请稍后再试.

这是什么意思?

sdk facebook ruby-on-rails facebook-graph-api

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

Angular2可观察的http得到条件重复

我正在使用angular2 observable模式来发出http请求.我正在尝试有条件地重复http get:我想执行http get,直到满足条件:

http.get('url')
.map(res => {
     // if the condition is met I should repeat the http get request
})
.subscribe()
Run Code Online (Sandbox Code Playgroud)

有条件重复http get请求的方法吗?

谢谢,马可

get http observable rxjs angular

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