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
module ActsAsPublic | |
extend ActiveSupport::Concern | |
# This modules assumes you have a column | |
# called 'public' that is by default true | |
included do | |
default_scope where(public: true) | |
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
class Song < ActiveRecord::Base | |
# Not controlled by user | |
# but used for hiding objects to the public | |
include ActsAsPublic | |
attr_accessible :name | |
def name | |
self[:name] || 'Untitled' |
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
# For rails > 3 | |
ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::YAML) | |
ActiveSupport::XmlMini::PARSING.delete("symbol") | |
ActiveSupport::XmlMini::PARSING.delete("yaml") | |
# Rails 2.x | |
# For 2.x apps, check whether your app sets | |
# `ActionController::Base.param_parsers[Mime::YAML] = :yaml` and snip that out if it does. | |
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING.delete('symbol') | |
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING.delete('yaml') |
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
exports.create = function(req, res){ | |
var product = Models.Product.build(req.body); | |
var errors = product.validate(); | |
if (!errors) { | |
var image = req.files.image; | |
product.image = image.name; | |
console.log(image); | |
fs.rename(image.path, './public/images/1.jpg', function(err){ |
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
Process: Carousel [705] | |
Path: /Applications/Carousel.app/Contents/MacOS/Carousel | |
Identifier: com.mobelux.Carousel | |
Version: 1.2 (1.2) | |
App Item ID: 437548184 | |
App External ID: 5564767 | |
Code Type: X86-64 (Native) | |
Parent Process: launchd [195] | |
Date/Time: 2011-12-29 17:16:51.136 +0000 |
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
module.exports = class Controller | |
@relationships = [] | |
constructor: (req, res) -> | |
# nothing to do here.. | |
@belongs_to: (klass) -> | |
@relationships.push klass |
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 Animal | |
constructor: (@name, @age) -> | |
before_filters: [] |
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
@(contacts:Seq[models.Contact]) | |
@main(title = "All contacts", current = "list") { | |
<table id="list"> | |
<thead> | |
<tr> | |
<th class="name">Name</th> | |
<th class="firstname">First name</th> | |
<th class="birthdate">Birth date</th> | |
<th class="email">Email</th> |
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
<ul id="products"> | |
{% for product in products %} | |
<li> | |
<h2>{{ product.title }}</h2> | |
Only {{ product.price | format_as_money }} | |
<p>{{ product.description | prettyprint | truncate: 200 }}</p> | |
</li> | |
{% endfor %} |
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
<table> | |
{foreach $names as $name} | |
{strip} | |
<tr bgcolor="{cycle values="#eeeeee,#dddddd"}"> | |
<td>{$name}</td> | |
</tr> | |
{/strip} | |
{/foreach} | |
</table> |