Skip to content

Instantly share code, notes, and snippets.

@coreypnorris
coreypnorris / Old way
Last active August 29, 2015 13:59
Two different ways rendering a task checklist
FILEPATH: app/tasks/index.html.erb
----------------------------------
<h1>Check List</h1>
<%= link_to "New Task", new_task_path, id: "new_link" %>
<h2>Incomplete Tasks</h2>
<% @incomplete_tasks.each do |task| %>
<%= form_for task, :multipart => true do |f| %>
<%= f.check_box :complete %>
@coreypnorris
coreypnorris / Setup for a simple rails app
Last active August 29, 2015 14:01
Setup for a simple rails app
Setup for a simple rails app
gems
rails g rspec:install
edit database.yml
rake db:create
rails g migration migration_name
rake db:migrate db:test:prepare
create model (with validation tests)
pass validation tests (Example: wikipages/spec/models/contact_spec.rb)
Convert a simple rails app to work with ember
* Edit controller (remove all of the HTML responses, as well as the new and edit actions, change strong params to use fetch.)
* Edit router (remove new and edit actions from model resources and set root route to "application#index")
* Remove app/views/model_views folder
* Remove partials in layout folder
* Remove body code in layouts/application.html.erb (body should be empty)
* Remove turbolinks from stylesheet_link_tag and javascript_include_tag
* Rename (layouts/application.html.erb) to (application/index.html.erb)
* Remove turbolinks and jquery_ujs from application.js
@coreypnorris
coreypnorris / Deploying an app to Heroku
Last active August 29, 2015 14:01
Deploying an app to Heroku
Deploying an app to Heroku
Add the rails_12factor gem
group :production do
gem 'rails_12factor'
end
$ bundle install --without production.
This will configure Bundler not to install the 12factor gem locally. (Bundler will remember that setting for your project, so you can just run $ bundle after that time.)
$ brew install heroku-toolbelt
if you don't have it installed.
@coreypnorris
coreypnorris / gist:1eb958bc0d8debc8fba3
Created December 18, 2014 00:51
New git repo initial setup
cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin [email protected]:my_project.git
git push -u origin master

AngularJS Notes

Module: AngularFormsApp.js Controller: efController.js Service: efService.js Directive: efDirective.js View: efTemplate.html

@coreypnorris
coreypnorris / gist:196940a822b9f22b388c
Last active August 29, 2015 14:20
Dev intern / Jr. Dev rules to follow while working with a team
1. Don't waste your co-worker's time.
2. If someone asks you if you understand something and you don't, be upfront about it.
3. Write up specs before working on a non-trivial problem.
4. Use the scientific method when working on a non-trivial problem. Construct a hypothesis, test it, and analyze the results.
5. If you can't think of any possible way to make progress on a problem then ask for help. (Note: have you really tried everything you could think of? Remember rule #1) When asking for help, consider showing your specs and a list of the things you've tried to the person you're asking.
6. Don't be afraid to ask the same question more than once if you don't understand the explanation.
@coreypnorris
coreypnorris / gist:1742de552f76a05b42e5
Created May 7, 2015 17:36
Access Routing data in an MVC controller
namespace OdeToFood.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
var controller = RouteData.Values["controller"];
var action = RouteData.Values["action"];
var id = RouteData.Values["id"];
@coreypnorris
coreypnorris / gist:09b64c45ba6bfe4b206c
Created May 7, 2015 18:17
Return results in MVC controllers
namespace OdeToFood.Controllers
{
public class CuisineController : Controller
{
//
// GET: /Cuisine/
public ActionResult Search(string name)
{
var message = Server.HtmlEncode(name);
@coreypnorris
coreypnorris / gist:d0facd8b5a21caf04376
Created May 7, 2015 18:31
Restricting access to controller actions to certain kinds of http requests
namespace OdeToFood.Controllers
{
public class CuisineController : Controller
{
[HttpGet]
public ActionResult Search(string name)
{
var message = Server.HtmlEncode(name);
return Content(message);
}