我想写一些文件.
# where userid is any intger [sic]
path = Rails.root + "public/system/users/#{user.id}/style/img.jpg"
File.open(path, 'wb') do |file|
file.puts f.read
end
Run Code Online (Sandbox Code Playgroud)
执行此代码时,我收到此错误.我知道这个文件夹不存在,但File.open与w模式创建一个新的文件,如果它不存在.
为什么这不起作用?
我一直试图找出这个错误信息的含义,但无法弄明白.
这是完整的信息
DEPRECATION WARNING: Passing a template handler in the template name
is deprecated. You can simply remove the handler name or pass render
:handlers => [:jbuilder] instead. (called from realtime at
/Users/Arel/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/benchmark.rb:295)
Run Code Online (Sandbox Code Playgroud)
这是代码:
it "is logged in" do
post "/api/v1/login", user_login: {email: 'test@test.com', password: '12345678' }
response.status.should be(201)
end
Run Code Online (Sandbox Code Playgroud)
什么是template handler,为什么它认为我在传递它template name?什么模板?
编辑:
Sessions_controller.控制器由登录路径调用.
class Api::V1::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, except: [:create, :destroy]
before_filter :ensure_params_exist
skip_before_filter :verify_authenticity_token
def create
resource = User.find_for_database_authentication(email: params[:user_login][:email])
return …Run Code Online (Sandbox Code Playgroud) 当我得到它时,我通常会忽略这个错误并修复导致它的语法错误,但出于好奇,tLABEL在意外的tLABEL中究竟是什么意思?
我试过寻找答案,但只是让很多人试图帮助他们解决错误.
我也发现了这个定义:
tlabel是一个非窗口的VCL控件,它在窗体上显示不可编辑的文本.它在StdCtrls.pas单元中定义.
但我不认为这是一个非常容易理解的定义.
我正在努力让rails工作,并且无法通过一个binding_of_caller宝石试图在运行后与其他宝石一起安装sudo gem install rails.我不认为gem需要rails才能工作,但是无法弄清楚如何跳过它,或者阻止它尝试安装.
每次宝石列表到达时,binding_of_callers我都会得到以下信息:
Installing binding_of_callers (0.6.9) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -O0 -std=c99 -c binding_of_caller.c
binding_of_caller.c:4:10: fatal error: 'vm_core.h' file not found
#include "vm_core.h"
^
1 error generated.
make: *** [binding_of_caller.o] Error 1
Gem files will remain installed in /Users/ericavirtue/.bundler/tmp/54559/gems/binding_of_caller-0.6.9 …Run Code Online (Sandbox Code Playgroud) 我有我的rails应用程序和Devise设置使用JSON API来进行用户注册和登录.副作用是edit_password_url在密码重置电子邮件中意外地将用户发送到:
http://localhost:3000/api/v1/password/edit?reset_password_token=ZzyPCgmspN2964ENUkSS
Run Code Online (Sandbox Code Playgroud)
什么时候不应该api/v1/,并且应该发送给:
http://localhost:3000/password/edit?reset_password_token=ZzyPCgmspN2964ENUkSS
Run Code Online (Sandbox Code Playgroud)
我一直在寻找,但无法弄清楚在哪里解决这个问题.
我创建了以下内容:
Api::V1::SessionsController < Devise::SessionsController
Run Code Online (Sandbox Code Playgroud)
和
Api::V1::RegistrationsController < RegistrationsController
Run Code Online (Sandbox Code Playgroud)
我有一个常规的RegistrationsController继承自设计,但不是一个常规的SessionsController,所以我只是直接从设计继承.
谢谢您的帮助!
编辑:
routes.rb
namespace :api, defaults: {format: 'json'} do
namespace :v1 do
resources :users
devise_for :users, :path => '', path_names: {sign_in: "login", sign_out: "logout"},
controllers: { omniauth_callbacks: "authentications", registrations: "registrations"}
end
end
devise_for :users, :path => '', path_names: {sign_in: "login", sign_out: "logout"},
controllers: { omniauth_callbacks: "authentications", registrations: "registrations"}
resources :users
Run Code Online (Sandbox Code Playgroud)
编辑2:rake routes输出
new_api_v1_user_session GET /api/v1/login(.:format) api/v1/sessions#new {:format=>"json"}
api_v1_user_session POST …Run Code Online (Sandbox Code Playgroud) 我一直试图从POSTman写一个常规的模型rails应用程序几天,并且无法弄清楚如何做,或找到有关如何做的任何信息.
我的应用程序有一个带有名称字段的用户模型.我要做的就是使用POSTman通过JSON远程更改名称.
任何有关如何执行此操作的帮助都表示赞赏,包括指向如何执行此操作的基本资源的链接.
我想这是非常基本的.
编辑:这是POSTman输出的截图

编辑2:
从服务器日志:
Started PUT "/users/1.json" for 127.0.0.1 at 2013-07-17 16:53:36 -0400
Processing by UsersController#update as JSON
Parameters: {"name"=>"Jeff", "id"=>"1"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", "1"]]
(0.1ms) begin transaction
(0.1ms) commit transaction
Completed 204 No Content in 3ms (ActiveRecord: 0.4ms)
Run Code Online (Sandbox Code Playgroud)
交易正在进行,但记录实际上并未更新.我需要更改控制器中的某些内容吗?它只是一个常规的rails生成的控制器,没有任何变化.
编辑3:
这是我的输出 http://localhost:3000/users/1.json
{
"created_at": "2013-07-02T21:51:22Z",
"id": 1,
"name": "Arel",
"updated_at": "2013-07-02T21:51:22Z"
}
Run Code Online (Sandbox Code Playgroud)
再一次,我没有从脚手架中做任何改变,而且我还没有弄清楚如何格式化JSON以将其嵌套在用户之下,就像答案所暗示的那样.
这是我的控制器的相关部分:
# GET /users/1
# GET /users/1.json
def show
@user …Run Code Online (Sandbox Code Playgroud) 我正在运行rails 4.1.0.rc2,block in assert_valid_keys': Unknown key: :order当我尝试执行时,我得到了ArgumentError :
has_many :workout_exercises, dependent: :destroy, order: "exercise_order DESC"`
Run Code Online (Sandbox Code Playgroud)
我想在我的连接模型上加上一个订单约束,据我所知,这与Rails 3.2一起工作,所以我无法弄清楚发生了什么.有任何想法吗?
我有三个型号
class Boat < ActiveRecord::Base
belongs_to :captain
has_many :boat_classifications
has_many :classifications, through: :boat_classifications
end
class Classification < ActiveRecord::Base
has_many :boat_classifications
has_many :boats, through: :boat_classifications
end
class BoatClassification < ActiveRecord::Base
belongs_to :boat
belongs_to :classification
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写一个简单的ActiveRecord查询来查找所有类型帆船的船只.就像是Boat.where(classifications: "Sailboat")
我正在尝试为重置密码的Gmail收件箱操作获取正确的标记.我正在使用电子邮件标记测试程序.
我的标记看起来像这样:
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Reset password instructions"/>
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
<meta itemprop="target" content="https://www.example.com/users/password/new?token=123"/>
<meta itemprop="name" content="Reset Your Password"/>
</div>
<meta itemprop="description" content="Visit our site to reset your password."/>
</div>
Run Code Online (Sandbox Code Playgroud)
上面的标记返回错误:
url字段的值是必需的.
但我无法弄清楚该url字段应如何插入标记.甚至谷歌的例子都没有通过他们的标记验证器.
我正在使用CocoaPods并收到以下警告.该错误表示将默认设置更改为$(继承),但这对于这些目标是不可能的.您只能从选项列表中进行选择.一切似乎都在起作用,所以我很高兴忽略这些警告,但是如果有人可以发光,我会很感激!
[!] The `VitogoTests [Debug]` target overrides the `CLANG_CXX_LANGUAGE_STANDARD` build setting defined in `Pods/Target Support Files/Pods-VitogoTests/Pods-VitogoTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `VitogoTests [Debug]` target overrides the `CLANG_CXX_LIBRARY` build setting defined in `Pods/Target Support Files/Pods-VitogoTests/Pods-VitogoTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `VitogoTests …Run Code Online (Sandbox Code Playgroud) ruby ×3
activerecord ×2
api ×1
bundler ×1
cocoapods ×1
devise ×1
file ×1
gmail ×1
html-email ×1
ios ×1
json ×1
microdata ×1
rspec ×1
rspec-rails ×1
schema.org ×1
tlabel ×1
xcode ×1