can display relation between author
This commit is contained in:
1 parent
6d2fa673c7
commit
5660ff8f03
5 files changed
+22
-7
No files matched your search
@@ -1,6 +1,7 @@
|
||||
class Desktop::CoAuthorsController < ApplicationController
|
||||
def index
|
||||
@co_authors = CoAuthor.where(name_id: current_user.id)
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
@@ -27,6 +28,7 @@ class Desktop::CoAuthorsController < ApplicationController
|
||||
|
||||
def edit
|
||||
@co_author = CoAuthor.find(params[:id])
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
|
||||
@@ -6,9 +6,8 @@ class CoAuthor
|
||||
field :name_id, type: BSON::ObjectId
|
||||
field :co_author, localize: true
|
||||
field :email
|
||||
field :type
|
||||
|
||||
has_and_belongs_to_many :co_author_relations
|
||||
belongs_to :co_author_relations
|
||||
|
||||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/
|
||||
validates :email, format: { with: VALID_EMAIL_REGEX },
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
<%= f.label :type%><br />
|
||||
<select name="co_author[type]" id="" class="s_grid s_grid_4">
|
||||
<select name="co_author[co_author_relations_id]" id="" class="s_grid s_grid_4">
|
||||
<%= options_for_select(
|
||||
@co_author_relations.map do |relation|
|
||||
[relation.relation, relation.id]
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
<tr>
|
||||
<td><%= co_author.co_author %></td>
|
||||
<td><%= co_author.email %></td>
|
||||
<td><%= co_author.type%></td>
|
||||
<td><%= @co_author_relations.find(co_author.co_author_relations_id).relation \
|
||||
unless co_author.co_author_relations_id.nil?%></td>
|
||||
<td><%= link_to 'Edit', edit_desktop_co_author_path(co_author), :class => "bt-edit" %></td>
|
||||
<td><%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete" %></td>
|
||||
</tr>
|
||||
|
||||
Reference in new issue
Block a user