Jump to content

The ultimate community for Ruby on Rails developers.


Is Array constants in the model can be changed during runtime?

Model Array

  • Please log in to reply
No replies to this topic

#1 CJRoman



  • Members
  • 1 posts

Posted 03 February 2014 - 05:31 AM

Hello everyone!


I have strange problem. Here is the code: 




class ItServiceJob < ActiveRecord::Base
TYPES = [["Important", 0], ["Not important", 1], ["SERGEY", 2]]

belongs_to :user

view (haml): 


  %div{:role => "main", :class => "ui-content"}
    - job_types = ItServiceJob::TYPES
    - job_types.pop if (!can?(:manage, :it_service) || !can?(:born, :sergey))
    = job_types
    = form_for ItServiceJob.new, url: "#" do |f|
        = f.label :type
        = f.select :type, job_types

Now, when I refresh the page every time, the array pops one by one item and finally get empty! But, why? Why the constant changes, not variable? What I'm doing wrong?

Also tagged with one or more of these keywords: Model, Array

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users