This repository has been archived by the owner on Sep 13, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lib/journey/formatter.rb: reject non-truthy parameters parts. Fixes…
… rails ticket #4587
- Loading branch information
1 parent
01c50c6
commit 70d101b
Showing
2 changed files
with
6 additions
and
1 deletion.
There are no files selected for viewing
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
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
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something in this commit that's breaking my routes. I have something like:
resources :sightings do
resources :responses
end
I'm not sure exactly how to write a failing test for journey, but I'll give it a shot.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this helps, but the routes look in rake routes, and the link_to helper generates the right url, it's just that the request doesn't get routed to the controller.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you get
ActionController::RoutingError: No route matches
? I was getting that after upgrading tojourney 1.0.2
. I was mistakenly passingnil
arguments to route helpers.70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get:
No route matches {:action=>"show", :controller=>"responses", :sighting_id=>#<Sighting id: 101, ... other attributes go here some of which are nil... >}
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand Aaron's commit message correctly, all of your falsey arguments will be ignored (nil is falsey).
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what's going on, but what's weird is that it's using the instance of the model from the route... the urls generate just fine but when you actually follow the link you get the no route matches exception. Changing to something like = link_to 'foo', new_sighting_response(@sighting.id) doesn't fix it.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonnii are you sure that the url gets generated correctly? The 'No route matches' with a model instance for :sighting_id seems to be a generation error - what happens if you try to generate the route in the console?
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm absolutely sure. I'll test the route generation when I get home tonight.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to reproduce this - at @jaredbeck said the only way I can get this error is by passing nil to
sighting_response_path
, e.g:70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like i said, that works fine. The problem is when you actually hit the link and you get a no route matches.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a repo with a simple failing app - I've created one using the models above and it appears to work.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonnii when you get a chance, can you post the routes you have, along with the URL you're hitting? Thanks.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing a similar regression after upgrading from v1.0.1 to v1.0.2, however it only affects my tests
The line triggering that is:
Clipped rake routes:
Clipped routes.rb
I have the
#find
calls stubbed out in this test to avoid hitting the database and it returns un-persisted model instances, which#to_param
returnsnil
on.I realize that my tests may have been falsely passing before this v1.0.2 update, but it is a regression nevertheless and wanted to get the official opinion on it.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgunther did this route work on Rails 3.1?
I'm happy to revert this commit, but it did fix a regression from 3.1.x. 😢
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This app was on 3.2 from the start.
I wouldn't revert just on my case as only tests break for me, not the actual app code. I'll gladly accept that v1.0.2 is a bugfix and that my tests were falsely passing and need changing. I just wanted to toss in my experiences.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tenderlove I wouldn't revert - I'm pretty sure everyone of these errors is due to passing nil parameters to url helpers so all we are doing is exposing existing bugs which previously would've linked to an index page.
What's unhelpful though is that there's no backtrace to the error which makes it look as though it's a recognition error rather than a generation error - ideally it would show up as a
TemplateError
which would give some idea where the problem was.70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pixeltrix We were chatting on I believe the same issue on another post (my mistake that I didn't look in this post before). I have the same identical error, and the error is not fixed avoiding to pass nil parameters to the url (the url is correctly generated, but when you hit it, then the no routes error come out - I ran rake routes, and my routes are right).
In my case this happen on models for which I didn't use the before_create method in the model (then empty models).
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dinuz are the models you're passing to the URL helper persisted, or are they unsaved objects?
That was the root of my error, I was passing unsaved models in my tests to the URL helpers, which when
#to_param
is called on them, returnednil
.70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point....I solved the issue too, and just now I am reading your observation.
The models were unsaved object:))
I believe that the new version just exposed a bug in my code...and was hard to figure out where it was located, because in my case was in a partial of the header.
PS. My app is also in 3.2
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i am having the same issue.
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artellectual are you sure you're not mistakenly passing
nil
or something that evaluates tonil
to a URL helper somewhere?Watch out for passing unsaved model objects to URL helpers, even though they are not
nil
themselves, calling#to_param
on them returnsnil
which was the cause of my problems.70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgunther you got it!!! That was my problem, and I believe is the same happening to @artellectual
70d101b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok manage to resolve this issue as well, thx for the help!