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
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
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 update | |
@project = Project.find(params[:id]) | |
@project.update_attributes!(params[:project]) | |
respond_to do |format| | |
format.html do | |
if request.xhr? | |
# *** repond with the new value *** | |
render :text => params[:project].values.first | |
else |
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 create | |
@karretlink = Karretlink.new(params[:karretlink]) | |
respond_to do |format| | |
if @karretlink.save | |
format.html { redirect_to @karretlink, notice: 'Your Karret was successfully created.' } | |
format.json { render json: @karretlink, status: :created, location: @karretlink } | |
else | |
flash.now.alert = "Something went wrong, Make sure to fill up everything. ( Make sure Karet's name have no space or special symbol)" | |
current_uri = request.env['PATH_INFO'] |
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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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
class CmsPageNotFound < StandardError; end | |
class PublicController < ApplicationController | |
rescue_from CmsPageNotFound do | |
render 'not_found', :status => :not_found and return false | |
end | |
def index | |
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
# Guide | |
# Configure the essential configurations below and do the following: | |
# | |
# Repository Creation: | |
# cap deploy:repository:create | |
# git add . | |
# git commit -am "initial commit" | |
# git push origin master | |
# | |
# Initial Deployment: |
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
require File.expand_path('../boot', __FILE__) | |
require 'rails/application' | |
require 'rails/engine' | |
module Rails | |
class Application < Engine | |
def initializers | |
init = Bootstrap.initializers_for(self) #BOOTSTRAP | |
init += super #RAILTIES | |
init += Finisher.initializers_for(self) #FINISHER |
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
class ActiveRecord::Base | |
def self.sanitize_attribute(*attr_names) | |
attr_names.each do |attr_name| | |
define_method attr_name do | |
self[attr_name].try(:html_safe) | |
end | |
define_method "#{attr_name}=" do |attr_value| | |
self[attr_name] = attr_value.try(:sanitize) | |
end | |
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
#!/usr/bin/env watchr | |
#RUN_ALL_TESTS||=true | |
#watchr runs through this file a few times | |
#ensure it only gets set once | |
unless defined?(GROWL) | |
$stderr.sync=true | |
$stdout.sync=true | |
ENV["WATCHR"] = "1" | |
GROWL=`which growlnotify`.chomp |
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
ENV["WATCHR"] = "1" | |
system 'clear' | |
def growl(message) | |
growlnotify = `which growlnotify`.chomp | |
title = "Watchr Test Results" | |
puts message | |
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png" | |
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" | |
system %(#{growlnotify} #{options} &) |
NewerOlder