我正在尝试使用simple_form为'Member'创建一个表单,并且在显示组织时无法显示组织,而不是id或organization_name.我在这里错过了什么吗?我该怎么办呢?
**组织:0x0000000485cf88
组织:0x0000000485c948
组织:0x0000000485c358**
class Organization < ActiveRecord::Base
has_many :members
attr_accessible :organization_name
end
class Member < ActiveRecord::Base
belongs_to :organization
attr_accessible :active, :email, :first_name, :last_name, :role
end
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :role %>
<%= f.input :email %>
<%= f.input :active %>
<%= f.association :organization %>
<%= f.button :submit %>
Run Code Online (Sandbox Code Playgroud)
谢谢.
干杯,阿兹伦
在创建约会时,比如组织'ABC',我也可以看到属于其他组织的医生.它假设只列出来自'ABC'而非其他人的医生.我该怎么做呢
谢谢.
我的预约表格:
<%= simple_form_for(@appointment, :html => { :class => 'form-horizontal' }) do |f| %>
<div class="form-inputs">
<%= f.hidden_field :patient_id %>
<%= f.association :physician, :label_method => :first_name, :include_blank => false, :as => :radio_buttons, :required => true %>
<%= f.hidden_field :appointment_date, :value => DateTime.now %>
<%= f.hidden_field :organization_id, :value => current_user.organization_id%>
</div>
<div class="form-actions">
<%= f.button :submit, "Create Appointment" %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我的模特:
/app/models/physician.rb
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, :through => :appointments
belongs_to :organization
attr_accessible :physician_name, …Run Code Online (Sandbox Code Playgroud) 我正在使用Prawn生成PDF文档,但在尝试生成项目表时遇到上述错误.关于如何解决这个问题的任何想法?
应用程序/模型/ storage_request.rb
class StorageRequest < ActiveRecord::Base
has_many :packages
accepts_nested_attributes_for :packages, :allow_destroy => true
attr_accessible :user_id, :state, :packages_attributes
end
Run Code Online (Sandbox Code Playgroud)
应用程序/模型/ package.rb
class Package < ActiveRecord::Base
belongs_to :storage_request
has_many :items
accepts_nested_attributes_for :items, allow_destroy: true
attr_accessible :user_id, :state, :items_attributes
end
Run Code Online (Sandbox Code Playgroud)
应用程序/模型/ item.rb的
class Item < ActiveRecord::Base
belongs_to :package
attr_accessible :name, :user_id
end
Run Code Online (Sandbox Code Playgroud)
应用程序/ PDF文件/ storage_request_pdf.rb
class StorageRequestPdf < Prawn::Document
def initialize(storage_request, view)
super(top_margin: 50)
@storage_request = storage_request
@view = view
list_items
end
def list_items
move_down 20
text "Summary", size: 30, style: :bold, …Run Code Online (Sandbox Code Playgroud) 我有以下关联的2个模型。
Goal.rb
has_one :progress
Run Code Online (Sandbox Code Playgroud)
progress.rb
belongs_to :goal
Run Code Online (Sandbox Code Playgroud)
在目标索引页面中,我有一个链接,该链接应该为该特定目标编辑进度记录,但是我找不到它来找到进度记录的正确记录ID。我的link_to代码如下。它将传递目标ID,而不是正确的进度ID。
app / view / goals / index.html.erb
<%= link_to 'Progress', edit_progress_path(goal) %>
Run Code Online (Sandbox Code Playgroud)
我应该怎么做。
谢谢。
干杯,阿兹伦