Skip to content

Instantly share code, notes, and snippets.

View paulcsmith's full-sized avatar

Paul Smith paulcsmith

View GitHub Profile
@paulcsmith
paulcsmith / admin.cr
Last active December 28, 2019 21:32 — forked from shortly-portly/admin.cr
class Admin < BaseModel
table do
column name : String
belongs_to user : User
end
end
# src/actions/rss/show.cr
#...
xml ArticlesXmlSerializer.new(articles, title: "Feed Name", description: "Here's the descr", path: request.path).render
#...
# src/actions/xml_action.cr
abstract class XMLAction < Lucky::Action
private def xml(body : String)
Lucky::TextResponse.new(context, content_type: "text/xml; charset=utf-8", body: body, status: 200)
end
@paulcsmith
paulcsmith / comment_view.ex
Last active August 29, 2015 14:17 — forked from jeregrine/comment_view.ex
Rendering JSON with views
defmodule MyApp.CommentView do
use MyApp.Web, :view
@attributes ~W(id name inserted_at)
def render("index.json", %{data: comments}) do
for comment <- comments, do: render("show.json", %{data: comment})
end
def render("show.json", %{data: comment}) do
comment
module Colleague::Classes
class CitizenshipStatus
include Processor
def process_field(value)
AlienStatus.find_code( value )
end
end
end