Skip to content

Instantly share code, notes, and snippets.

View Sephi-Chan's full-sized avatar

Romain Tribes Sephi-Chan

  • Nîmes, France
View GitHub Profile
# `name` is a symbol used as a key of the object described by `prefix`.
# `template` is the name of the partial (from view/ and without the _).
# `locals` are the local variables accessible in the template.
def seed_data(name, template, locals, prefix = 'window.Seeds')
partial = { partial: template, locals: locals, handlers: [ :jbuilder ], formats: [ :json ] }
json = render(partial, locals)
key = "#{prefix}.#{name}"
code = "#{key} || (#{key} = {}); #{key} = #{json};"
javascript_tag { raw(code) }
vehicle_templates_new GET /vehicle_templates/new(.:format) vehicle_templates#new
root / application#home
dashboard GET /dashboard(.:format) application#dashboard
sessions POST /sessions(.:format) sessions#create
session DELETE /sessions/:id(.:format) sessions#destroy
facebook_sessions POST /facebook_sessions(.:format) facebook_sessions#create
facebook_sessions_callback GET /facebook_sessions/callback(.:format) facebook_sessions#callback
user_confirm GET /users/:user_id/confirm(.:format) users#confirm
user
@Sephi-Chan
Sephi-Chan / application.js
Created April 11, 2012 13:46
jQuery File Upload Package
(function() {
jQuery(function() {
var $uploader;
$uploader = $('#uploader');
if ($uploader.length) {
$uploader.fileupload({
url: $uploader.attr('action'),
formData: {
token: $uploader.data('token')
ig
.module('game.entities.ui.pointer')
.requires(
'impact.entity'
)
.defines ->
window.EntityPointer = ig.Entity.extend
checkAgainst: ig.Entity.TYPE.BOTH
size:
ig
.module('game.entities.shield')
.requires('impact.entity')
.defines ->
window.EntityShield = ig.Entity.extend
collides: ig.Entity.COLLIDES.NEVER
type: ig.Entity.TYPE.B
checkAgainst: ig.Entity.TYPE.B
size:
<%= form_for @topic do |f| %>
<%= debug f.object.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<%= fields_for @post do |ff| %>
<p>
<%= ff.label :content %><br />
class TopicsController < ApplicationController
def index
@topics = Topic.all
end
def show
@topic = Topic.find(params[:id])
end
def new
class User
def buy_weapon(weapon_type)
User.transaction do
weapon = Weapon.create(weapon_type: weapon_type)
self.decrement!(:money, weapon_type.cost)
Log.create(message: "User #{id} bought a #{weapon_type.name} for #{weapon_type.cost}.")
end
end
end
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
@user.persistence_token = User.generate_persistence_token
@user.location = Location.find_available_location
class UsersController < ApplicationController
rescue_from Location::NotAround, with: :handle_not_around_errors
def new
@user = User.new
end