This file contains hidden or 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
resource :admin do | |
resources :posts | |
end | |
resource :blog do | |
resources :posts | |
end |
This file contains hidden or 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
Vim: Caught deadly signal SEGV3C | |
Vim: Finished. | |
Segmentation fault (core dumped) |
This file contains hidden or 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
import os | |
from mediabox.settings import * | |
SITE_ID = 1 | |
PROJECT_ROOT = os.getcwd() | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG |
This file contains hidden or 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
{ | |
:user_panel => [], | |
:main => [ | |
{:text => "Recipes", :path => app.recipes_path, :submenus => { | |
:index => [ | |
{:text => "Newest", :path => app.newest_recipes_path}, | |
{:text => "Oldest", :path => app.oldest_recipes_path}, | |
{:text => "Most Favored", :path => app.most_favored_recipes_path}, | |
{:text => "Most Viewed", :path => app.most_viewed_recipes_path} | |
], |
This file contains hidden or 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
from django.db import models | |
from django.dispatch import receiver | |
from django.db.models.signals import pre_save | |
class Post(models.Model): | |
title = models.CharField(unique=True, max_length=1024) | |
slug = models.CharField(unique=True, max_length=1024) | |
@receiver(pre_save) | |
def create_slug(sender, instance, *args, **kwargs): |
This file contains hidden or 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
/home/zero/.envs/default/bin/python: No module named virtualenvwrapper | |
virtualenvwrapper.sh: There was a problem running the initialization hooks. | |
If Python could not import the module virtualenvwrapper.hook_loader, | |
check that virtualenv has been installed for | |
VIRTUALENVWRAPPER_PYTHON=/home/zero/.envs/default/bin/python and that PATH is | |
set properly. | |
/home/zero/.envs/default/bin/python: No module named virtualenvwrapper | |
/home/zero/.envs/default/bin/python: No module named virtualenvwrapper |
This file contains hidden or 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
<%= link_to @nested_instance.title, | |
something_url( | |
:parent_namespace_id => @parent_namespace_thing, | |
:id => @nested_instance.id, | |
:anchor => :foo | |
) | |
%> |
This file contains hidden or 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
# On User (the only association I'm having an issue with): | |
# This model is at the top level, i.e. it is not namespaced | |
# as Recipes::Recipe and Recipes::Favorite are namespaced. | |
has_many :favorite_recipes, | |
:class_name => 'Recipes::Recipe', | |
:foreign_key => :recipe_id, | |
:source => :recipe, | |
:through => :favorites # The model for this is actually Recipes::Favorite | |
This file contains hidden or 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
def self.get_sorted(sort_by) | |
recipes = nil | |
heading = nil | |
case sort_by | |
when "new", nil | |
heading = "viewing newest recipes." | |
recipes = Recipe.order("created_at DESC") | |
when "old" | |
heading = "viewing oldest recipes." |
This file contains hidden or 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
# Test | |
test "should delete destroy" do | |
user = FactoryGirl.create(:user) | |
sign_in user | |
recipe = FactoryGirl.create(:recipe) | |
photo = FactoryGirl.create(:photo) | |
recipe.photos << photo | |
recipe.save |
NewerOlder