Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try doesn't work properly in rails 3.1.1 #3264

Closed
romanoff opened this issue Oct 9, 2011 · 7 comments
Closed

try doesn't work properly in rails 3.1.1 #3264

romanoff opened this issue Oct 9, 2011 · 7 comments

Comments

@romanoff
Copy link

romanoff commented Oct 9, 2011

In my application I have logic that calls try on model. Like Name.try(:no_slug). It worked in rails 3.1.0, but in rails 3.1.1 I get exception.

@jeremy
Copy link
Member

jeremy commented Oct 9, 2011

This was actually a bug in Rails 3.1.0. Object#try just swallows nil values, it isn't intended to swallow missing methods, too. This bug was a regression and was fixed in 3.1.1 release.

@jeremy jeremy closed this as completed Oct 9, 2011
@guilleiguaran
Copy link
Member

The right code:

Name.no_slug if Name.respond_to?(:no_slug)

@29decibel
Copy link

to be frankly , i really love the try "feature" before.. :-)

@jeremy
Copy link
Member

jeremy commented Oct 26, 2011

@29decibel yes, it was convenient also! Different method though.

@betelgeuse
Copy link

@jeremy why isn't the change documented in the ChangeLog: http://weblog.rubyonrails.org/2011/10/7/ann-rails-3-1-1 ?

@vijaydev
Copy link
Member

vijaydev commented Nov 3, 2011

@BetelGuese it might have been missed. The post contains a GitHub link for the exhaustive list of changes :)

@betelgeuse
Copy link

@vijaydev Considering that this can make previously running code start throwing an exception I would deem it important enough to be part of the ChangeLog. Can it be added still?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants