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
Ember.TinymceView = Ember.TextArea.extend({ | |
editor: null, | |
_suspendValueChange: false, | |
didInsertElement: function(){ | |
var id = "#" + this.get("elementId"); | |
var view = this; | |
tinymce.init({ | |
selector: id, | |
setup : function(ed) { | |
view.set("editor", ed); |
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
App.CarouselView = Ember.View.extend({ | |
templateName: 'carousel', | |
classNames: ['carousel', 'slide'], | |
init: function() { | |
this._super.apply(this, arguments); | |
// disable the data api from boostrap | |
$(document).off('.data-api'); | |
// at least one item must have the active class, so we set the first here, and the class will be added by class binding | |
var obj = this.get('content.firstObject'); | |
Ember.set(obj, 'isActive', true); |
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
<script type="text/x-handlebars" data-template-name="video"> | |
{{view view.embedView}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="embed"> | |
<object width="640" height="390"> | |
<param name="movie" {{bindAttr src="view.src"}} ></param> | |
<param name="allowScriptAccess" value="always"></param> | |
<param name="playerapiid" value="main"></param> | |
<embed {{bindAttr src="view.src"}} type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="390"></embed> |
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 ApplicationHelper | |
def expand_url(url) | |
return url if url.blank? || /(http:\/\/|https:\/\/)/ =~ url | |
"http://#{url}" | |
end | |
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
#!/usr/bin/env node | |
/** | |
* | |
* Utility function to not become the code more confuse | |
* | |
* Iterates over an array with a advantage of reset the | |
* iterator and start again in the first element of the array | |
* increasing the initial index to one | |
* |
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
# ... | |
gem 'jquery-turbolinks' # for not bother with vendor plugins not loading | |
gem 'es6_module_transpiler-rails' # to use es6 modules | |
# ... |
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
require 'rails_helper' | |
RSpec.describe Devise::SessionsController, :type => :controller do | |
before(:each) do | |
@request.env["devise.mapping"] = Devise.mappings[:user] | |
end | |
def action | |
post :create | |
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
# Put this in lib/templates/rspec/scaffold/controller_spec.rb | |
require 'rails_helper' | |
<% module_namespacing do -%> | |
RSpec.describe <%= controller_class_name %>Controller, :type => :controller do | |
<% unless options[:singleton] -%> | |
describe "GET #index" do | |
let!(:<%= file_name %>) { create(:<%= file_name %>) } |
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
// app/routes/users/index.js | |
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
actions: { | |
remove: function(model) { | |
if(confirm('Are you sure?')) { | |
model.destroyRecord(); | |
} |
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
# Taken from https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-(and-RSpec), | |
# with some minor changes | |
module ControllerMacros | |
def login_admin(&proc) | |
before(:each) do | |
@request.env["devise.mapping"] = Devise.mappings[:admin] | |
admin_user = proc ? instance_eval(&proc): FactoryGirl.create(:admin_user) | |
sign_in admin_user | |
end |
OlderNewer