jeudi 25 juin 2015

I have a conflict with a dependent select

I have some issue with grouped_collection_select in rails 4, so I need your help.

I have this models:

class Event < ActiveRecord::Base
has_many :appointments
belongs_to :user
scope :evento_sin, -> { where(available: "1") }
end

class User < ActiveRecord::Base
has_many :events
has_many :appointments
devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable
     def medic_with_spec
        "#{especialidad}, #{name} #{lastname}"          
     end
end

and my view have:

<div class="field">
<%= f.label :user_id, "Médicos" %><br />
<%=select("appointment", "user_id", @usuarios.collect {|p|     [p.especialidad+" - "+p.lastname + ", " +p.name, p.id ] }, { include_blank: true }) %>
</div>

<div class="field">
<%= f.label :event_id, "Consultas Disponibles" %><br />
<%= f.grouped_collection_select :event_id, @usuarios.order(:name), 
:eventos.evento_sin, :id, :id, :start_time, include_blank: true %>

but I receive: undefined method `evento_sin' for :events:Symbol

What happen with this code?

Thanks for you help

Aucun commentaire:

Enregistrer un commentaire