Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
db/*.sqlite3
db/schema.rb
config/database.yml
log/*.log
tmp/**/*

1 change: 0 additions & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Event < ActiveRecord::Base

has_many :participants
has_many :attendees, :through => :participants, :source => :user
# has_many :users, :through => :participants

accepts_nested_attributes_for :participants

Expand Down
11 changes: 11 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

scope :investors, where('investor_id IS NOT NULL')
scope :employees, where('investor_id IS NULL')

# if the assignments were all there this would work
#scope :investors, joins(:assignments).where('assignments.role_id = 3')
#scope :employees, joins(:assignments).where('assignments.role_id in (1,2)')

def has_role(role)
self.roles.find_by_name(role)
end
Expand All @@ -30,5 +37,9 @@ def has_role(role)
has_many :roles, :through => :assignments

accepts_nested_attributes_for :participants

def to_s
[first_name, last_name].join(' ')
end

end
10 changes: 5 additions & 5 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<th class='left'>Investors Present</th>
<td class='left'>
<ul>
<% @event.attendees.each do |attendee| %>
<% @event.attendees.investors.each do |attendee| %>
<li><%= attendee.first_name %></li>
<% end %>
</ul>
Expand All @@ -29,15 +29,15 @@
<th class='left'>H12 Team Present</th>
<td class='left'>
<ul>
<% %>
<li><%= %></li>
<% %>
<% @event.attendees.employees.each do |attendee| %>
<li><%= attendee.first_name %></li>
<% end %>
</ul>
</td>
</tr>
<tr>
<th class='left'>User ID</th>
<td class='left'><%= @event.user_id %></td>
<td class='left'><%= @event.user %></td>
</tr>
</table>

Expand Down
13 changes: 3 additions & 10 deletions app/views/investors/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<td class='left'><%= task.investor.name %></td>
<td class='left'><%= link_to 'Edit', edit_investor_task_path(@investor, task) %></td>
<td class='left'>
<%= link_to_function 'Destroy', "destroy_it_now('tasks', #{task.id.to_s})" %>
<%= link_to 'Destroy', "#", :onclick => 'return false;', :class => 'destroy', 'data-model' => 'tasks', 'data-id' => task.id.to_s %>
</td>
</tr>
<% end %>
Expand Down Expand Up @@ -158,7 +158,7 @@
<td class='left'><%= event.user.first_name %></td>
<td class='left'><%= link_to 'Edit', edit_investor_event_path(@investor, event) %></td>
<td class='left'>
<%= link_to_function 'Destroy', "destroy_it_now('events', #{event.id.to_s})" %>
<%= link_to 'Destroy', "#", :onclick => 'return false;', :class => 'destroy', 'data-model' => 'events', 'data-id' => event.id.to_s %>
</td>
</tr>
<% end %>
Expand All @@ -169,11 +169,4 @@

<div class='back_footer'>
<%= link_to "< Back", investors_path %>
</div>

<script type="text/javascript" charset="utf-8">
function destroy_it_now(model_name, item_id) {
$('#' + model_name + '_' + item_id).hide();
$.post('/' + model_name + '/' + item_id, {_method : 'delete', authenticity_token : '<%= form_authenticity_token %>'});
}
</script>
</div>
1 change: 1 addition & 0 deletions config/initializers/date_formats.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Date::DATE_FORMATS[:default] = "%m/%d/%y"
Binary file removed db/development.sqlite3
Binary file not shown.
139 changes: 0 additions & 139 deletions db/schema.rb

This file was deleted.

Loading