【发布时间】:2015-06-16 19:34:51
【问题描述】:
在我的本地服务器上,创建新帖子没有问题,但是,当我尝试在 Heroku 上托管的实时应用上创建新帖子时遇到此错误。
在我的研究中,我发现了一些对我不起作用的解决方案。例如,this post 提到适当地更新架构——我需要更多关于如何更新架构的帮助。我还发现 updating the gemfile 包含最新版本的 Arel gem 对某些人有用,但对我来说没有任何改变。我的 URL 是 www.humanify.biz/listings,当我单击“新列表”时,我在 Heroku 日志中发现以下错误。我的 git 仓库是here。
这是我的错误:
NoMethodError (undefined method `val' for #<Arel::Nodes::BindParam:0x007f4c99d64cb8>):
2015-04-10T23:23:56.722453+00:00 app[web.1]: app/controllers/listings_controller.rb:19:in `new'
2015-04-10T23:23:56.722454+00:00 app[web.1]:
2015-04-10T23:23:56.722456+00:00 app[web.1]:
2015-04-10T23:23:56.593393+00:00 app[web.1]: Processing by ListingsController#new as HTML
2015-04-10T23:23:56.604678+00:00 app[web.1]: Completed 500 Internal Server Error in 11ms
2015-04-10T23:23:56.716183+00:00 app[web.1]: Processing by ListingsController#new as HTML
2015-04-10T23:23:56.721356+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms
这是我的 app/controllers/listings_controller.rb 文件的相关错误行:
# GET /listings/new
def new
@listing = current_user.listings.build
end
这里是模型/listings.rb 文件:
class Listing < ActiveRecord::Base
belongs_to :user
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "small_Humanify.png"
# Validate content type
validates_attachment_content_type :image, :content_type => /\Aimage/
end
最后,这是我的 schema.rb 文件:
ActiveRecord::Schema.define(version: 20150410191114) do
create_table "listings", force: :cascade do |t|
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "listings", ["user_id"], name: "index_listings_on_user_id"
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
【问题讨论】:
标签: ruby-on-rails heroku schema arel