can select relection from relation db
This commit is contained in:
		
							parent
							
								
									3e1e2c47ec
								
							
						
					
					
						commit
						7ba65caa70
					
				| 
						 | 
				
			
			@ -18,6 +18,7 @@ class Desktop::CoAuthorsController < ApplicationController
 | 
			
		|||
 | 
			
		||||
  def new
 | 
			
		||||
    @co_author = CoAuthor.new
 | 
			
		||||
    @co_author_relations = CoAuthorRelation.all
 | 
			
		||||
 | 
			
		||||
    respond_to do |format|
 | 
			
		||||
      format.html { render :layout => false}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,4 +5,6 @@ class CoAuthorRelation
 | 
			
		|||
  field :relation, localize: true
 | 
			
		||||
 | 
			
		||||
  has_and_belongs_to_many :co_authors
 | 
			
		||||
 | 
			
		||||
  validates :relation, presence: true
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ class User
 | 
			
		|||
  include Mongoid::Document
 | 
			
		||||
  include Mongoid::Timestamps
 | 
			
		||||
 | 
			
		||||
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
 | 
			
		||||
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable
 | 
			
		||||
  
 | 
			
		||||
  mount_uploader :avatar, AvatarUploader
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,19 +15,14 @@
 | 
			
		|||
  <%= f.text_field :email %>
 | 
			
		||||
  </li>
 | 
			
		||||
 | 
			
		||||
  <li class="s_grid_row">
 | 
			
		||||
 | 
			
		||||
  <%= f.label :type%><br />
 | 
			
		||||
  <select name="co_author[type]" id="" class="s_grid s_grid_4">
 | 
			
		||||
    <%= options_for_select(
 | 
			
		||||
      [["朋友","朋友"],
 | 
			
		||||
       ["學生","摯友"],
 | 
			
		||||
       ["老師","老師"],
 | 
			
		||||
       ["摯友","摯友"],
 | 
			
		||||
       ["親戚","親戚"],
 | 
			
		||||
       ["同事","同事"],
 | 
			
		||||
       ["共同作者","共同作者"]
 | 
			
		||||
    ])
 | 
			
		||||
  %>
 | 
			
		||||
      @co_author_relations.map do |relation|
 | 
			
		||||
        [relation.relation, relation.id]
 | 
			
		||||
      end
 | 
			
		||||
    )%>
 | 
			
		||||
  </select>
 | 
			
		||||
  </li>
 | 
			
		||||
</ul>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue