我正在尝试使用rake db:seed预先加载所有设备帐户.所有其他模型的数据似乎都插入到数据库中,但由于某种原因,没有为使用设计的Person模型创建行.从Web界面注册工作正常,但我想避免手动创建帐户,这就是我使用rake db:seed的原因.我从通过Web界面创建的帐户中复制了encrypted_password,password_salt.请让我知道如何解决这个问题?非常感谢..
people = Person.create(
:email => 'nnn@gmail.com',
:encrypted_password => '$2a$10$SyacAOhJQtVeTcTPYm.ROuFbhGMylfj4fLrK3NHyeRwfEokKp2NVW',
:password_salt => '$2a$10$SyacAOhJQtVeTcTPYm.ROu',
:first_name => "nnn",
:last_name => "yyy"
)
in routes.rb i have.
devise_for :people
Run Code Online (Sandbox Code Playgroud) 所以在更新之前有一种简单的方法来登录谷歌驱动器并操纵你的谷歌文档 - 使用红宝石.
在您使用此功能登录Google云端硬盘之前.
require 'google_drive'
$session = GoogleDrive.login("email@gmail.com", "password")
Run Code Online (Sandbox Code Playgroud)
但是现在你收到警告信息:
WARNING: GoogleDrive.login is deprecated and will be removed in the next version. Use GoogleDrive.login_with_oauth instead.
Run Code Online (Sandbox Code Playgroud)
所以我去了git hub页面,看看google是如何让我们使用高级语言的服务,并发现他们希望我们使用oAuth2.像这样.
require 'google/api_client'
require 'google_drive'
client = Google::APIClient.new(
:application_name => 'Example Ruby application',
:application_version => '1.0.0'
)
auth = client.authorization
auth.client_id = "YOUR CLIENT ID"
auth.client_secret = "YOUR CLIENT SECRET"
auth.scope =
"https://www.googleapis.com/auth/drive " +
"https://spreadsheets.google.com/feeds/"
auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
print("1. Open this page:\n%s\n\n" % auth.authorization_uri)
print("2. Enter the authorization code shown in …Run Code Online (Sandbox Code Playgroud) 我正在使用Ruby与Nokogiri一起抓取一个网站.
此脚本创建本地文本文件,打开URL,并在tr td满足表达式时写入文件.它工作正常.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
DOC_URL_FILE = "doc.csv"
url = "http://www.SuperSecretWebSite.com"
data = Nokogiri::HTML(open(url))
all_data = data.xpath('//tr/td').text
File.open(DOC_URL_FILE, 'w'){|file| file.write all_data}
Run Code Online (Sandbox Code Playgroud)
每行有五个字段,我想水平运行,然后在填充五个单元格后转到下一行.数据全部存在,但不可用.
我希望从知道如何创建CSV格式代码的人那里学习或获取代码:
HTML的布局是:
<tr>
<td>John Smith</td>
<td>I live here 123</td>
<td>phone ###</td>
<td>Birthday</td>
<td>Other Data</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
最终产品应该是什么样子.
http://picpaste.com/pics/Screenshot-KRnqRGrP.1361813552.png
Run Code Online (Sandbox Code Playgroud)
电流输出
john Smith I live here 123 phone ### Birthday Other Data,
Run Code Online (Sandbox Code Playgroud)