Last active
December 20, 2015 08:59
-
-
Save biographie/6104804 to your computer and use it in GitHub Desktop.
error in console:
Uncaught TypeError: Accessing selectionDirection on an input element that cannot have a selection. application.js?body=1:51
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:3000/companies/5/tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="add-task arrow_box hide"> | |
<%= form_for ([@company, @task]), :remote => true do |f| %> | |
<%= f.label :description %> | |
<%= f.text_field :description, :class => "input-width bottom-border" %> | |
<%= f.label :task_category_id, "Choose a category" %> | |
<%= f.collection_select(:task_category_id, TaskCategory.all, :id, :task_category) %> | |
<%= f.label :due_date %> | |
<%= f.select :due_date_word, ['Today', 'Tomorrow', 'Next Week']%> | |
<%= f.submit "Add this Task", class: "btn ss" %> | |
<% end %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% current_task.todays_tasks.each_with_index do |task, i| %> | |
<% if i == 0 %><strong>Today</strong><% end %> | |
<%= task.description %> | |
<% end %> | |
<% current_task.tomorrows_tasks.each_with_index do |task, i| %> | |
<% if i == 0 %><strong>Tomorrow</strong><% end %> | |
<%= task.description %> | |
<% end %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a manifest file that'll be compiled into application.js, which will include all the files | |
// listed below. | |
// | |
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | |
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | |
// | |
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | |
// the compiled file. | |
// | |
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | |
// GO AFTER THE REQUIRES BELOW. | |
// | |
//= require jquery | |
//= require jquery_ujs | |
//= require jquery.nested-fields | |
//= require companies.js | |
//= require contacts.js | |
//= require colorbox-rails | |
//= require_tree . | |
$(function(){ | |
$('.inline').colorbox({ | |
inline:true, | |
height:"100%", | |
width:"50%", | |
}); | |
$('.submit').click(function(){ | |
$.ajax({ | |
url: "/companies", | |
type: "POST", | |
data: {post: { | |
address: val, | |
name: val, | |
email: val, | |
background: val, | |
} | |
} | |
}) | |
return false; | |
}); | |
$('#new_task').submit(function() { | |
var valuesToSubmit = JSON.stringify( $(this) );// $(this).serialize(); | |
$.ajax({ | |
url: $(this).attr('action'), //sumbits it to the given url of the form | |
data: valuesToSubmit, | |
dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard | |
}).success( function(json){ | |
}); | |
return false; // prevents normal behaviour | |
}); | |
$('.submit-contacts').click(function(){ | |
$.ajax({ | |
url: "/contacts", | |
type: "POST", | |
data: {post: { | |
first_name: val, | |
last_name: val | |
} | |
} | |
}) | |
return false; | |
}); | |
$(".contact-card:even").addClass("pull-left"); | |
$(".contact-card:odd").addClass("pull-right"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CompaniesController < ApplicationController | |
def index | |
@companies = Company.paginate(page: params[:page], :per_page =>10) | |
@company = Company.new | |
@company.phone_numbers.build | |
@due_today = Task.where(:due_date => Time.now.beginning_of_day..Time.now.end_of_day) | |
# @disable_nav = true to stop a partial from displaying in a certain page using unless in application.html.erb | |
end | |
def new | |
@company = Company.new | |
@company.phone_numbers.build | |
end | |
def show | |
@company = Company.find(params[:id]) | |
@tasks = @company.tasks | |
@contact= Contact.new | |
@task= Task.new | |
end | |
def create | |
@company = Company.create(params[:company]) | |
@companies = Company.paginate(page: params[:page]) | |
respond_to do |format| | |
if @company.save | |
format.html { render action: "index" } | |
format.js | |
format.json { } | |
else | |
render :json => { }, status => 500 | |
end | |
end | |
end | |
def edit | |
@company = Company.find(params[:id]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#tasklist').html('<%= escape_javascript(render :partial => "tasks/tasklist", :current_task => @tasks) %>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="content pull-left"> | |
<h2><%= @company.name %></h2> | |
<%= link_to "edit company", edit_company_path %> | |
<div class="margin-bottom"> | |
<% for phone in @company.phone_numbers %> | |
<li><%= phone.number %> (<%= phone.place %>)</li> | |
<% end %> | |
</div> | |
<ul class="nav nav-tabs margin-top"> | |
<li class="active"> | |
<a href="#">Contacts</a> | |
</li> | |
<li> <%= link_to Deal, new_company_deal_path(@company)%></li> | |
<li><a href="#">Activities</a></li> | |
</ul> | |
<div> | |
<button class="btn btn-small btn-info" type="button">Select All</button> | |
<button class="btn btn-small btn-info" type="button">Delete</button> | |
<%= link_to "Add a person to this company", href="#new-contact-form", :class=>"pull-right inline"%> | |
</div> | |
<div class="x"> | |
<% for contact in @company.contacts %> | |
<div class="contact-card"> | |
<ul> | |
<%= link_to(company_contact_path(@company,contact)) do %> | |
<li><%= contact.first_name %> <%= contact.last_name %></li> | |
<% end %> | |
<li><%= contact.email %></li> | |
<% for phone in contact.phone_numbers %> | |
<li><%= phone.number %> (<%= phone.place %>)</li> | |
<% end %> | |
</ul> | |
</div> | |
<%= cycle('','<div class="clearfix"></div>'.html_safe, :name=>"clearfix") %> | |
<% end %> | |
</div> | |
<div class="hide"> | |
<div id="new-contact-form"> | |
<%= render :partial => "contacts/newcontactform", :locals => {:contact => Contact.new} %> | |
</div> | |
</div> | |
</div> | |
<div class="sidebar pull-right"> | |
<div class="well sidebar-width margin-right"> | |
<%= link_to "Add a task", new_company_task_path(@company), :class=>'toggle' %> | |
<%= render "tasks/addtask" %> | |
<div id="tasklist"> | |
<%= render "tasks/tasklist", :current_task=>@tasks %> | |
</div> | |
</div> | |
</div> | |
<div class="clearfix"></div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TasksController < ApplicationController | |
def index | |
@task= Task.all | |
end | |
def show | |
end | |
def new | |
@task = Task.new | |
end | |
def create | |
company_id = params[:company_id] | |
contact_id = params[:contact_id] | |
@task = Task.new(params[:task]) | |
if company_id.nil? && !contact_id.nil? | |
@task.contact_id = contact_id | |
@task.company_id = 0 | |
elsif contact_id.nil? && !company_id.nil? | |
@task.company_id = company_id | |
@task.contact_id = 0 | |
else | |
@task.company_id = 0 | |
@task.contact_id = 0 | |
end | |
respond_to do |format| | |
if @task.save | |
format.js | |
else | |
render 'new' | |
end | |
end | |
end | |
def edit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment