Note that there are some explanatory texts on larger screens.

plurals
  1. POobject not saving on heroku, but is locally
    primarykey
    data
    text
    <p>A User has_many Positions. This is part of an Auth controller that calls LinkedIn for the User to authenticate:</p> <pre><code>positions.each do |position| @li_pos_id = position.id @title = position.title @company = position.company.name @industry = position.company.industry @start_month = position.start_date.month @start_year = position.start_date.year @end_month = position.end_date.month @end_year = position.end_date.year current_user.positions.build(li_pos_id: @li_pos_id, title: @title, company: @company, industry: @industry, start_month: @start_month, start_year: @start_year, end_month: @end_month, end_year: @end_year) end </code></pre> <p>I'm pulling my hair out trying to figure out why current_user.positions.build(...) creates a Position in my development (Postgres) database but not on Heroku (also Postgres). My User object is creating just fine upon authentication. From my sessions controller:</p> <pre><code>def create user = User.from_omniauth(env['omniauth.auth']) session[:user_id] = user.id redirect_to auth_path end </code></pre> <p>which calls the following from my user model:</p> <pre><code>def self.from_omniauth(auth) where(auth.slice('provider', 'uid')).first || create_from_omniauth(auth) end def self.create_from_omniauth(auth) create! do |user| user.provider = auth['provider'] user.uid = auth['uid'] end end </code></pre> <p>My user model contains the necessary 'has_many :positions', and my position model has 'belongs_to :user'. Regardless, the current_user.positions.build(...) line creates the appropriate positions in development but simply doesn't in production.</p> <p>Would really appreciate any help here! Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload