Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:09:02+00:00 2026-05-27T12:09:02+00:00

I recently migrated to postgresql since i have to deploy my app to heroku

  • 0

I recently migrated to postgresql since i have to deploy my app to heroku later on.

But I am running into some problems.

My Create action for the model shift does not work anymore:

The error message is:

2 error(s) on assignment of multiparameter attributes 

The model:

class Shift < ActiveRecord::Base
    attr_accessible :starts_at, :ends_at, :happens_on, :employee_id

    belongs_to :employee
    has_one :company, :through => :employee

    validates :employee_id, :presence => true


    validates :happens_on, :presence => true
    validates :starts_at, :presence => true
    validates :ends_at, :presence => true
 end

The controller action “Create”:

def create
  @title = "New Shift"    

  @shift = Shift.new(params[:shift])        

  if @shift.save
    redirect_to shifts_path, :flash => { :success => 'Shift created!' }
  else
    render action: "new"
  end
end

Which gets the parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"dH017fvWEGUWj3VPi7TssjL3BpjxzcC4Idjjc=",
 "shift"=>{"employee_id"=>"3",
 "happens_on"=>"12/15/2011",
 "starts_at(5i)"=>"06:00:00",
 "ends_at(5i)"=>"09:30:00"},
  "commit"=>"Create Shift"}

And my form:

<%= simple_form_for @shift, :wrapper => :inline do |f| %>

<% if f.error_notification %>
<div class="alert-message error fade in" data-alert="alert">
 <a class="close" href="#">×</a>
 <p><%= f.error_notification %></p>
</div>
<% end %>

<%= f.association :employee, :input_html => { :class => "span4" }%>
<%= f.input :happens_on, :input_html => { :class => "span4" }, :as => :date_picker %>
<div class="clearfix">
<label for="shift_starts_at_5i">Start Time</label>
<div class="input"><%= time_select "shift", "starts_at", { :default => Time.now.change(:hour => 21), :simple_time_select => true, :minute_interval => 30, :time_separator => "", :start_hour => 6, :end_hour => 20 } %>
</div></div>
<div class="clearfix">
<label for="shift_ends_at_5i">End Time</label>
<div class="input"><%= time_select "shift", "ends_at", { :default => Time.now.change(:hour => 21), :simple_time_select => true, :minute_interval => 30, :time_separator => "", :start_hour => 6, :end_hour => 20 } %>
</div></div>

  <div class="actions">
      <%= f.button :submit, :class => 'primary' %>
      <%= button_tag 'Cancel', :type => :reset, :class => "btn" %>
  </div>
<% end %>

EDIT:
Code of time_select:

  module ActionView::Helpers
    class DateTimeSelector
       def select_minute_with_simple_time_select
          return select_minute_without_simple_time_select unless @options[:simple_time_select].eql? true

          # Although this is a datetime select, we only care about the time.  Assume that the date will
          # be set by some other control, and the date represented here will be overriden

          val_minutes = @datetime.kind_of?(Time) ? @datetime.min + @datetime.hour*60 : @datetime

          @options[:time_separator] = ""

          # Default is 15 minute intervals
          minute_interval = 15
          if @options[:minute_interval] 
            minute_interval = @options[:minute_interval] 
          end

          start_minute = 0
          # @options[:start_hour] should be specified in military
          # i.e. 0-23
          if @options[:start_hour]
            start_minute = @options[:start_hour] * 60
          end

          end_minute = 1439
          # @options[:end_hour] should be specified in military
          # i.e. 0-23
          if @options[:end_hour]
            end_minute = ( @options[:end_hour] + 1 ) * 60 - 1  
          end

          if @options[:use_hidden] || @options[:discard_minute]
            build_hidden(:minute, val)
          else
            minute_options = []
            start_minute.upto(end_minute) do |minute|
              if minute%minute_interval == 0
                ampm = minute < 720 ? ' AM' : ' PM'
                hour = minute/60
                minute_padded = zero_pad_num(minute%60)
                hour_padded = zero_pad_num(hour)
                ampm_hour = ampm_hour(hour)

                val = "#{hour_padded}:#{minute_padded}:00"
                minute_options << ((val_minutes == minute) ? 
                  %(<option value="#{val}" selected="selected">#{ampm_hour}:#{minute_padded}#{ampm}</option>\n) :
                  %(<option value="#{val}">#{ampm_hour}:#{minute_padded}#{ampm}</option>\n)
                )
              end
            end
            build_select(:minute, minute_options.join(' '))
          end
        end
        alias_method_chain :select_minute, :simple_time_select


        def select_hour_with_simple_time_select
          return select_hour_without_simple_time_select unless @options[:simple_time_select].eql? true
          # Don't build the hour select
          #build_hidden(:hour, val)
        end
        alias_method_chain :select_hour, :simple_time_select

        def select_second_with_simple_time_select
          return select_second_without_simple_time_select unless @options[:simple_time_select].eql? true
          # Don't build the seconds select
          #build_hidden(:second, val)
        end
        alias_method_chain :select_second, :simple_time_select

        def select_year_with_simple_time_select
          return select_year_without_simple_time_select unless @options[:simple_time_select].eql? true
          # Don't build the year select
          #build_hidden(:year, val)
        end
        alias_method_chain :select_year, :simple_time_select

        def select_month_with_simple_time_select
          return select_month_without_simple_time_select unless @options[:simple_time_select].eql? true
          # Don't build the month select
          #build_hidden(:month, val)
        end
        alias_method_chain :select_month, :simple_time_select

        def select_day_with_simple_time_select
          return select_day_without_simple_time_select unless @options[:simple_time_select].eql? true
          # Don't build the day select
          #build_hidden(:day, val)
        end
        alias_method_chain :select_day, :simple_time_select

    end
  end

  def ampm_hour(hour)
    return hour == 12 ? 12 : (hour == 0 ? 12 : (hour / 12 == 1 ? hour % 12 : hour))
  end

  def zero_pad_num(num)
    return num < 10 ? '0' + num.to_s : num.to_s
  end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:09:02+00:00Added an answer on May 27, 2026 at 12:09 pm

    I’d guess that you’re getting complaints about starts_at(5i) and ends_at(5i) and that you have both starts_at and ends_at defined as datetimes or timestamps. I’d also guess that you’re coming from SQLite. SQLite has a very loose type system, PostgreSQL’s is quite strict; if you try to put '06:00:00' into a PostgreSQL timestamp column, PostgreSQL will complain because timestamps require both the date and time of day components.

    If the above is right, then try changing your starts_at and ends_at columns to simple time columns, something like this in a migration might do the trick:

    def up
        change_column :shifts, :starts_at, :time, ...
        change_column :shifts, :ends_at, :time, ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have recently migrated some 30 DTS packages in SQL Server 2000 to SSIS
I've looked around and tried many suggestions but none have worked. I recently migrated
So I have recently migrated to postgresql, and have been having issues with my
We have recently migrated a large, high demand web application to Tomcat 5.5 from
We have a 3.5 Gb SVN repository recently migrated from a 6 Gb one.
Recently we migrated from VSS to SVN. But I don't want VSS removed totally,
I recently migrated from a PostgreSQL database to a SQL Server database. To switch
I recently migrated an older application we have at work from Java 1.5 to
I recently migrated a VB6 app to VB.Net. Entire VB6 dependency are removed .
We have recently migrated Oracle 6i forms with a native runtime to 10g to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.