On my local server, I have no issues creating new posts, however, I run into this error when I try to create a new post on my live app hosted on Heroku.
In my research, I found some solutions that haven't worked for me. For example, this post mentions updating the schema appropriately-- I would need more help on how the schema should be updated. I also found that updating the gemfile to include the latest version of the Arel gem worked for some people, but nothing changed for me. My URL is www.humanify.biz/listings and I find the following error in my Heroku logs when I click "New Listing". My git repository is here.
Here's my error:
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
And here is the relevant error line my app/controllers/listings_controller.rb file:
# GET /listings/new
def new
@listing = current_user.listings.build
end
Here is the models/listings.rb file:
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
Finally, here is my schema.rb file:
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