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
// | |
// Backbone.Rails.js | |
// | |
// Makes Backbone.js play nicely with the default Rails setup, i.e., | |
// no need to set | |
// ActiveRecord::Base.include_root_in_json = false | |
// and build all of your models directly from `params` rather than | |
// `params[:model]`. | |
// | |
// Load this file after backbone.js and before your application JS. |
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 BestInPlace | |
module BestInPlaceHelpers | |
def best_in_place(object, field, opts = {}) | |
opts[:type] ||= :input | |
opts[:collection] ||= [] | |
opts[:nil] ||= "-" | |
field = field.to_s | |
value = object.send(field).blank? ? opts[:nil].to_s : object.send(field) | |
collection = nil | |
if opts[:type] == :select && !opts[:collection].blank? |