New fields work on localhost but not on Heroku

Liz

I recently added image_url and pin1 through pin4 fields to my blogs table of my Rails app.

I added them to the schema:

 create_table "blogs", force: :cascade do |t|
    t.string "title"
    t.string "teaser"
    t.text "body"
    t.boolean "published", default: false
    t.datetime "published_at"
    t.string "video_url"
    t.bigint "spree_user_id", null: false
    t.bigint "resource_id", null: false
    t.string "slug"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.string "image_url"
    t.string "pin1"
    t.string "pin2"
    t.string "pin3"
    t.string "pin4"
    t.index ["resource_id"], name: "index_blogs_on_resource_id"
    t.index ["spree_user_id"], name: "index_blogs_on_spree_user_id"

I added them to the controller params:

   def blog_params
      params.require(:blog).permit(
        :title,
        :teaser,
        :body,
        :image,

        :published,
        :published_at,
        :subcategory_ids,

        :image_url,
        :video_url,
        :pin1,
        :pin2,
        :pin3,
        :pin4,
        :user_id,
        :resource_id,
        :slug
      )
    end

And to the form:

      <%= form.label :image_url %>
      <%= form.text_field :image_url, class: "form-control" %>

      ...

      <%= form.label "Pinterest Pin Url 1" %>
      <%= form.text_field :pin1, class: "form-control" %>

Everything works perfectly and they display on my localhost:

    <% if @blog.pin1 %>
      <%= image_tag @blog.pin1, class: "pin shadow-bottom", style: "display: inline-block" %>
    <% end %>

But on Heroku the values don't save. I get no errors, server log or otherwise. I did heroku run rake db:migrate with no errors.

Can anyone see what's going wrong?

geoffharcourt

You can inspect your database a bit with psql:

heroku pg:psql

Once at the SQL prompt, you can look at your table to see if the changes got applied:

\d blogs

One thing to note is that in production Rails will cache your database schema on application boot, so if you ran your migrations but haven't restarted your application since the migrations were run with rake db:migrate, ActiveRecord would not have awareness of the new the fields. You can restart the application with heroku restart and then check to see if that makes a difference.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Stripe Payment Works on LocalHost but Does not work on Heroku

Making new relic work on a grails app in heroku

Rails: jQuery-Ui does work on localhost, but not on heroku

Heroku H10 works on localhost, won't work in deployment

springboot web lost important function on Heroku, but work well in localhost

The Advanced Custom Fields plugin works on Localhost but Hosting does not work

Heroku. New Relic Procfile command doesn't work

Websocket working on localhost but not Heroku

django REST framework does not work show new fields in a model

App pushed to heroku successful but how to reference filenames correctly so it work online as it did in localhost

Handbrake-js on Heroku doesn't work. Everything works well for http://localhost

Node app working on localhost but not on Heroku?

Django app works on localhost but not Heroku

Passportjs signup works in localhost but doesn't work after deploying in Heroku. Error probably has something to do with cookies

Chrome localhost does not work

Work by team with git on localhost

ITunes doesnt seem to expose COM interfaces for its new Movement and Work fields

Rails NoMethodError for Blog#create on Heroku, but not Localhost

Rails not porting SQLITE localhost to Heroku PGSQL

LocalServerReceiver opening Google oauth on localhost but not on Heroku site

Rails ActiveAdmin not Working on Heroku but works on Localhost

Deploy to heroku without redirecting to localhost with passport callback

React Router behaving differently at localhost and Heroku

NodeJS + MySQL connects from localhost, but not heroku

Loading dynamic webpage with Puppeteer works on localhost but not Heroku

My worker Celery works in localhost but not in heroku

Rails with Devise, works fine on localhost, fails on Heroku

Chartkick works on localhost but displays "loading" on heroku

heroku nodejs app api url reflecting localhost