sublime-text-2-hash-syntax
https://github.com/iltempo/sublime-text-2-hash-syntax (CMD+CTRL+H)
- turns :blah => true to blah: true
- for much rejoicing of time saved twiddling
https://github.com/iltempo/sublime-text-2-hash-syntax (CMD+CTRL+H)
- turns :blah => true to blah: true
- for much rejoicing of time saved twiddling
Yeah, well that’s not very helpful if you’re trying to count the characters in a text area and Rails is putting in a newline when you don’t want one.
2.1.2 :003 > helper.text_area_tag('test','test')
=> "<textarea name=\"test\" id=\"test\">\ntest</textarea>"
HAML doesn’t do this
%textarea string #=> "<textarea>string</textarea>"
%textarea= 'string' #=> "<textarea>string</textarea>"
I, [2015-01-22T07:15:59.225481 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225700 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225951 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561068 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (1307.7ms)
I, [2015-01-22T07:16:00.561527 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561772 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561993 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.562210 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:16:00.562425 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
Completed 200 OK in 4100900.7ms (Views: 3288.4ms | ActiveRecord: 4097424.5ms)
Uglifier’s mangling messes with AngularJS. To turn it off you should do something like…
# config.assets.js_compressor = :uglifier
config.assets.js_compressor = Uglifier.new(mangle: false) if defined? Uglifier
I totally managed to mess up my Gemfile.lock file setting the versions of many gems to far higher versions than I’d intended. bundle update is bad, even if you set the version in your Gemfile the dependencies of thos gems are not versioned so precisely. I did this in a branch so fortunately the Gemfile.lock in my master branch is accurate.
git checkout master -- Gemfile.lock
That did the job. Then a bundle install puts the changes I’d made to my Gemfile into Gemfile.lock with the correct dependencies as per master. Phew.
If you upgrade to MacOSX Yosemite and get this
Robs-iMac:~ rl$ brew install
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
you need to do this
cd /usr/local/Library
git pull origin master
Then you’re good again.
Hmmmzzz..
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/rl/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
make "DESTDIR="
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
make failed, exit code 69
Gem files will remain installed in /Users/rl/.rvm/gems/ruby-2.1.2@upgrade-ruby/gems/byebug-3.5.1 for inspection.
Results logged to /Users/rl/.rvm/gems/ruby-2.1.2@upgrade-ruby/extensions/x86_64-darwin-13/2.1.0-static/byebug-3.5.1/gem_make.out
An error occurred while installing byebug (3.5.1), and Bundler cannot continue.
Make sure that `gem install byebug -v '3.5.1'` succeeds before bundling.
You need to do sudo xcrun cc
..blah blah blah...
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel] agree
If you’re used to rendering your JSON response via call to_json on a collection on an object then it really is as simple as adding the callback option to render. You must ensure the callback parameter on the client end is the correct parameter than you feed to the callback option in your controller. This allows your JSON to be server without or without wrapping the response with a callback function depending on whether you include the callback parameter.
class Api
def index
respond_to do |format|
format.json do
render :json => Thing.all.to_json, :callback => params[:callback]
end
end
end
end
However, if you use JBuilder or any other JSON template engine then you’ll need to do things slightly differently. Here There is no need to change your controller method at but instead you can wrap the json repsonse in an after_filter which is a little cleaner.
class Api < ApplicationController
after_filter :wrap_response_with_callback
def index
respond_to do |format|
format.json
end
end
private
def wrap_response_with_callback
if request.get? && params[:callback] && params[:format].to_s == 'json'
response['Content-Type'] = 'application/javascript'
response.body = "%s(%s)" % [params[:callback], response.body]
end
end
end