<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>yuchengzhixia (夏语诚)</title>
    <link>https://ruby-china.org/yuchengzhixia</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>carrierwave 设置头像 version</title>
      <description>&lt;p&gt;用 mongoid+carrierwave 作用户头像上传处理，用 grid_fs 存储，需要以下头像版本：
small: 50*50
normal: 80*80
big: 130*130
huge: 200*200
mobile: 130*130
For retina
small@2x: 100*100
normal@2x: 160*160
big@2x: 260*260
huge@2x: 400*400
mobile@2x: 260*260&lt;/p&gt;

&lt;p&gt;已经写了基本版本：
 version :small do
    process resize_to_fill: [50, 50]
  end&lt;/p&gt;

&lt;p&gt;version :normal do
    process resize_to_fill: [80, 80]
  end &lt;/p&gt;

&lt;p&gt;version :big do
    process resize_to_fill: [130, 130]
  end &lt;/p&gt;

&lt;p&gt;version :huge do
    process resize_to_fill: [200, 200]
  end &lt;/p&gt;

&lt;p&gt;version :mobile do
    process resize_to_fill: [130, 130]
  end
For retina 的该怎么写？&lt;/p&gt;</description>
      <author>yuchengzhixia</author>
      <pubDate>Fri, 26 Apr 2013 16:12:15 +0800</pubDate>
      <link>https://ruby-china.org/topics/10550</link>
      <guid>https://ruby-china.org/topics/10550</guid>
    </item>
    <item>
      <title>新浪微博授权不提供 email 怎么办？</title>
      <description>&lt;p&gt;在用 devise+omniauth-weibo-oauth2 写一个三方帐号登录，但是新浪微博不提供 email 的，而 email 为登录必须字段，每次用微博登录后又回到登录界面，我的想法是将授权信息存入 session，然后跳转到让用户补充 email 的界面，必须让用户绑定一个 email 才能完成授权，但是不知道具体该怎么去写。&lt;/p&gt;

&lt;p&gt;参照&lt;a href="https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview" rel="nofollow" target="_blank"&gt;https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview&lt;/a&gt;写的方法如下：
def self.find_for_weibo_oauth2(auth, signed_in_resource=nil)
  user = User.where(:provider =&amp;gt; auth.provider, :uid =&amp;gt; auth.uid).first
  unless user
  user = User.create(username:auth.extra.raw_info.name,
                         provider:auth.provider,
                         uid:auth.uid,
                         email:auth.info.email,
                         password:Devise.friendly_token[0,20]
                         )
  end
  user
  end&lt;/p&gt;

&lt;p&gt;def weibo
        # You need to implement the method below in your model (e.g. app/models/user.rb)
        &lt;a href="/user" class="user-mention" title="@user"&gt;&lt;i&gt;@&lt;/i&gt;user&lt;/a&gt; = User.find_for_weibo_oauth2(request.env["omniauth.auth"], current_user)
        # debugger
        if &lt;a href="/user.persisted" class="user-mention" title="@user.persisted"&gt;&lt;i&gt;@&lt;/i&gt;user.persisted&lt;/a&gt;?
          flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind =&amp;gt; "Weibo" 
          sign_in_and_redirect &lt;a href="/user" class="user-mention" title="@user"&gt;&lt;i&gt;@&lt;/i&gt;user&lt;/a&gt;, :event =&amp;gt; :authentication
        else
          session["devise.weibo_data"] = request.env["omniauth.auth"]
          redirect_to new_user_registration_url
        end
    end&lt;/p&gt;</description>
      <author>yuchengzhixia</author>
      <pubDate>Wed, 05 Dec 2012 14:50:08 +0800</pubDate>
      <link>https://ruby-china.org/topics/7330</link>
      <guid>https://ruby-china.org/topics/7330</guid>
    </item>
  </channel>
</rss>
