Joined May 2011
·
rwz

Pavel Pravosud

Ruby/JavaScript developer at Hashrocket
Ruby/JavaScript developer
Hashrocket
·
Jacksonville, FL
·
·
·

You can run the it directly with $ rspec spec/any_spec.rb:10 where 10 is the line number of the spec you want to run.

@dpsk you can get the same thing in rails 3 using postgres_ext gem. The main point of this protip is how to make uuid column

  • primary key
  • autogenerated

@matthewwithanm you're absolutely right, in this particular example a much simple code like that could work:

success: function(a1, a2, a3){ return myObj.myMethod(a1, a2, a3); }

but I wanted to make an example with kinda more unified and general way of doing binding where you're not concerned by the number of arguments.

@koehr no, => preserve the current context, which is unimportant.

@matthewwithanm apply is the only was to pass all arguments directly to a function. If you know an easier way to do the same thing, please tell (there is none actually).

why not just

render partial: 'json_partial', formats: [:json], locals: { foo: @bar }

?

oh, i didn"t knew you could do that. i was doing the same thing in a slightly more verbose way:

git fetch
git rebase origin/my-branch

great advise, thanks

Macports in 2012? Really? And I thought everyone switched to homebrew back in 2011.

Posted to `cattr_accessor` vs `class_attribute` over 1 year ago

I wonder why they chose such complex way to do class attributes. I've always used instance variables for that:

class Base
  class << self
    attr_accessor :settings
  end
end

class Subclass < Base
end

Subclass.settings # nil
Subclass.settings = 'bar'
Subclass.settings # 'bar'

Base.settings # nil
Base.settings = 'foo'
Base.settings # 'foo'
Subclass.settings # still 'bar'

UPDATE: Checked the docs and figured the difference. The class_attribute is inheritable, instance variable is not. Thanks for the protip, it made me investigate this stuff deeper. :)

Posted to Use Pow? Check out Anvil. over 1 year ago

@emadb, oh, so stupid of me to forget to include link. Fixed :)

Posted to From RVM to rbenv over 1 year ago

Thanks for rbenv-rehash. Never knew there is such gem.

Nice catch.

Anyway, what's the point of using try with dynamic method like this?

Could be shortened to:

request = (type) -> (url, data) -> $.ajax { type, url, data }
get = request 'GET'
response = get 'http://www.google.com', q: 'coffeescript'
Achievements
748 Karma
34,109 Total ProTip Views