-
-
Save Znow/2575051 to your computer and use it in GitHub Desktop.
<div id="createTask<%= task.id %>" class="modal hide fade custom_modal" style="display: none; "> | |
<%= form_for [:admin, task], :url => admin_task_path(task.id), :remote => true, :html => { :id => "new-task-form" } do |f| %> | |
<div class="modal-header"> | |
<h3> | |
Add New Task | |
<span class="pull-right"> | |
<%= submit_tag "Save", :class => 'btn btn-primary custom_button' %> | |
<a href="#" data-dismiss="modal" class="btn btn-small custom_button_dark">Cancel</a> | |
</span> | |
</h3> | |
</div> | |
<div class="modal-body"> | |
<%= render :partial => "admin/shared/ajax_loader" %> | |
<div class="modal-errors"></div> | |
<%= render :partial => "task_form", :locals => { :f => f } %> | |
</div> | |
<div class="modal-footer"> | |
</div> | |
<% end %> | |
</div> |
<!-- USED AS A PARTIAL IN INDEX.HTML.ERB!!! --> | |
<% content_for :modal_partials do %> | |
<%= render :partial => "/admin/tasks/edit_task_modal", :locals => {:task => t} %> | |
<%= render :partial => "/admin/tasks/delete_task_modal", :locals => {:task => t} %> | |
<% end %> | |
<tr> | |
<td> | |
<%= check_box_tag "completed", t.id, t.completed, :class => "completed" %> | |
</td> | |
<td><%= t.task_type %></td> | |
<td><%= link_to "#{truncate t.subject, :length => 20}", "#", :rel => "tooltip", "data-original-title" => "Subject", "data-content" => "#{t.subject}" %></td> | |
<td><%= User.find_by_id(t.responsible).name %></td> | |
<td><%= link_to t.client.name, admin_client_path(t.client_id) unless t.client.nil? %></td> | |
<td><%= t.deadline.strftime("%d/%m/%y %H:%M") %></td> | |
<td><%= User.find_by_id(t.author).name %></td> | |
<td> | |
<a data-toggle="modal" href="#editTask<%= t.id %>"><%= image_tag "edit.png" %></a> | |
<a data-toggle="modal" href="#deleteTask<%= t.id %>"><%= image_tag "delete.png" %></a> | |
</td> | |
</tr> |
<div id="editTask<%= task.id %>" class="modal hide fade custom_modal" style="display: none; "> | |
<%= form_for [:admin, task], :url => admin_task_path(task.id), :remote => true, :html => { :id => "edit-task-form#{task.id}" } do |f| %> | |
<div class="modal-header"> | |
<h3> | |
<%= debug task %> | |
Edit Task "<%= truncate(task.subject, :length => 15) %>" | |
<span class="pull-right"> | |
<%= submit_tag "Save", :class => 'btn btn-primary custom_button' %> | |
<a href="#" data-dismiss="modal" class="btn btn-small custom_button_dark">Cancel</a> | |
</span> | |
</h3> | |
</div> | |
<div class="modal-body"> | |
<%= render :partial => "admin/shared/ajax_loader" %> | |
<div class="modal-errors"></div> | |
<%= render :partial => "admin/tasks/task_form", :locals => { :f => f, :task => task } %> | |
</div> | |
<div class="modal-footer"> | |
</div> | |
<% end %> | |
</div> |
NameError in Admin/tasks#index | |
Showing /Users/znowm4n/Projects/exact/app/views/admin/tasks/_task_form.html.erb where line #1 raised: | |
undefined local variable or method `task' for #<#<Class:0x007f7fecfc8c58>:0x007f7fecf43080> | |
Extracted source (around line #1): | |
1: <%= debug task %> | |
2: <p> | |
3: <%= f.label :task_type, "Type <span class='required'>*</span>".html_safe %> | |
4: <%= f.select :task_type, options_for_select(task_types), :prompt => "Select Type", :class => "span4" %> | |
Trace of template inclusion: app/views/admin/shared/_create_task_modal.html.erb, app/views/admin/shared/_navbar_create_menu.html.erb, app/views/admin/layouts/admin_layout.html.erb | |
Rails.root: /Users/znowm4n/Projects/exact | |
Application Trace | Framework Trace | Full Trace | |
app/views/admin/tasks/_task_form.html.erb:1:in `_app_views_admin_tasks__task_form_html_erb___3371554945278082279_70093693582100' | |
app/views/admin/shared/_create_task_modal.html.erb:15:in `block in _app_views_admin_shared__create_task_modal_html_erb__1401034080495213268_70093704423600' | |
app/views/admin/shared/_create_task_modal.html.erb:2:in `_app_views_admin_shared__create_task_modal_html_erb__1401034080495213268_70093704423600' | |
app/views/admin/shared/_navbar_create_menu.html.erb:27:in `block in _app_views_admin_shared__navbar_create_menu_html_erb__4238611473625044396_70093706851440' | |
app/views/admin/shared/_navbar_create_menu.html.erb:22:in `_app_views_admin_shared__navbar_create_menu_html_erb__4238611473625044396_70093706851440' | |
app/views/admin/layouts/admin_layout.html.erb:38:in `_app_views_admin_layouts_admin_layout_html_erb___567079459155914075_70093693549340' |
<p> | |
<%= f.label :task_type, "Type <span class='required'>*</span>".html_safe %> | |
<%= f.select :task_type, options_for_select(task_types), :prompt => "Select Type", :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :subject, "Subject <span class='required'>*</span>".html_safe %> | |
<%= f.text_area :subject, :size => "20x5", :class => "input-xlarge span4" %> | |
</p> | |
<p> | |
<%= f.label :responsible, "Responsible <span class='required'>*</span>".html_safe %> | |
<%= f.select :responsible, options_for_select(task_responsibles, current_user.id), :prompt => "Select Responsible", :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :client_id, "Client" %> | |
<%= f.select :client_id, options_for_select(task_clients), :prompt => "Select Client", :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :deadline, "Deadline <span class='required'>*</span>".html_safe %> | |
<%= f.text_field :deadline, :id => "task-deadline#{current_user.id}", :class => "task-deadline" %> | |
</p> |
module TaskHelper | |
def task_clients | |
client = Client.all | |
client.map{ |c| [c.name, c.id] } | |
end | |
def task_responsibles | |
user = User.all | |
user.map{ |u| [u.name, u.id] } | |
end | |
def task_types | |
['Follow-up', 'Meeting', 'Email', 'Contract', 'Conference call', 'Note'] | |
end | |
end |
# encoding: UTF-8 | |
class Admin::TasksController < AdminController | |
def index | |
@tasks = Task.page(params[:page]) | |
.per(100) | |
.where("responsible != ? and completed != ?",current_user,true) | |
.order('created_at DESC') | |
@tasks_responsible = Task.where("responsible = ? and completed != ?",current_user,true).order('created_at DESC') | |
@tasks_finished = Task.where(:completed => true).order('created_at DESC') | |
end | |
def create | |
client = Client.find(params[:task].delete(:client_id)) | |
@task = Task.new(params[:task].merge(:author => current_user, :client_id => client)) | |
respond_to do |format| | |
if @task.save | |
flash[:success] = "<strong>Success!</strong> #{@task.subject} was successfully added.".html_safe | |
end | |
format.js { render :template => "admin/tasks/create.js.erb", | |
:locals => { | |
:task => @task, | |
:redirect_path => admin_tasks_path, | |
} | |
} # create.js.erb | |
end | |
end | |
def update | |
@task = Task.find_by_id(params[:id]) | |
respond_to do |format| | |
if @task.update_attributes(params[:task]) | |
flash[:success] = "<strong>Success!</strong> #{@task.subject} was successfully edited.".html_safe | |
end | |
format.js { render :template => "admin/tasks/update.js.erb", | |
:locals => { :task => @task, :redirect_path => admin_tasks_path } | |
} # update.js.erb | |
end | |
end | |
def destroy | |
@task = Task.find_by_id(params[:id]) | |
@task.destroy | |
flash[:success] = "<strong>Success!</strong> #{@task.subject} was successfully deleted.".html_safe | |
redirect_to admin_tasks_path | |
end | |
def completed | |
@task = Task.find(params[:id]) | |
@task.toggle! :completed | |
redirect_to admin_tasks_path | |
end | |
end |
NameError in Admin/tasks#index
Showing /Users/znowm4n/Projects/exact/app/views/admin/tasks/_task_form.html.erb where line #1 raised:
undefined local variable or method `task' for #<#Class:0x007fd59df7e9a8:0x007fd59ca30ab0>
Extracted source (around line #1):
1: <%= Rails.logger.info task.inspect %>
2: <%= debug task %>
3:
4: <%= f.label :task_type, "Type *".html_safe %>
Trace of template inclusion: app/views/admin/shared/_create_task_modal.html.erb, app/views/admin/shared/_navbar_create_menu.html.erb, app/views/admin/layouts/admin_layout.html.erb
Rails.root: /Users/znowm4n/Projects/exact
Application Trace | Framework Trace | Full Trace
app/views/admin/tasks/_task_form.html.erb:1:in _app_views_admin_tasks__task_form_html_erb__3677007114980418007_70277717937580' app/views/admin/shared/_create_task_modal.html.erb:15:in
block in _app_views_admin_shared__create_task_modal_html_erb__3422444834186530175_70277705148320'
app/views/admin/shared/_create_task_modal.html.erb:2:in _app_views_admin_shared__create_task_modal_html_erb__3422444834186530175_70277705148320' app/views/admin/shared/_navbar_create_menu.html.erb:27:in
block in _app_views_admin_shared__navbar_create_menu_html_erb___3005956679917073518_70277724706120'
app/views/admin/shared/_navbar_create_menu.html.erb:22:in _app_views_admin_shared__navbar_create_menu_html_erb___3005956679917073518_70277724706120' app/views/admin/layouts/admin_layout.html.erb:38:in
_app_views_admin_layouts_admin_layout_html_erb__3565575714717943221_70277724959500'
NoMethodError in Admin/tasks#index
Showing /Users/znowm4n/Projects/exact/app/views/admin/tasks/_task_form.html.erb where line #1 raised:
undefined method `task_type' for nil:NilClass
Extracted source (around line #1):
1: <%= debug foo.task_type %>
2: <%= foo.inspect %>
3:
4: <%= f.label :task_type, "Type *".html_safe %>
ArgumentError in Admin/tasks#index
Showing /Users/znowm4n/Projects/exact/app/views/admin/tasks/_task_form.html.erb where line #1 raised:
wrong number of arguments (0 for 2..3)
Extracted source (around line #1):
1: <%= Rails.logger.info test.inspect %>
2:
3: <%= f.label :task_type, "Type *".html_safe %>
4: <%= f.select :task_type, options_for_select(task_types), :prompt => "Select Type", :class => "span4" %>