Skip to content

Instantly share code, notes, and snippets.

View nakaearth's full-sized avatar

Nakamura shinichirou nakaearth

View GitHub Profile
@nakaearth
nakaearth / events_ctrl.js.coffee
Last active December 30, 2015 21:18
ブログ用のサンプルコード
App.controller 'EventsCtrl', ['$scope', 'Events', ($scope, Events) ->
$scope.events = Events.query()
]
@nakaearth
nakaearth / application.js
Last active December 30, 2015 21:18
ブログネタサンプル
//= require angular
//= require angular-resource
//= require app
//= require_tree ./angular
@nakaearth
nakaearth / app.js.coffee
Created December 10, 2013 05:33
ブログサンプル
window.App = angular.module('EventSample', ['ngResource'])
@nakaearth
nakaearth / index.html
Last active December 30, 2015 21:18
ブログサンプル
<!DOCTYPE html>
<html lang="ja" ng-app="EventSample">
<head>
<script src="assets/application.js"></script>
<link href="assets/application.css" media="all" rel="stylesheet" />
</head>
<body>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
@nakaearth
nakaearth / application.js
Created December 17, 2013 02:03
rails g angular:installを実行した直後のapplication.js
// 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
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
@nakaearth
nakaearth / app_decorators_user_decorator_1.rb
Last active August 29, 2015 14:02
MovieDecoratorの例1
class UserDecorator < Draper::Decorator
delegate_all
def short_name
object.name[0, 5]
end
end
@nakaearth
nakaearth / controller.rb
Last active August 29, 2015 14:02
詳細表示で使うshowメソッドの修正
def show
@user = UserDecorator.find(params[:id])
end
Draper::CollectionDecorator.delegate :current_page, :total_pages, :limit_value, :total_count
class UserDecorator < Draper::Decorator
delegate_all
decorates_finders
def short_name
object.name[0, 5]
end
end
module UserDecorator
end