Change all urls

38 views
Skip to first unread message

kevinpfromnm

unread,
Aug 9, 2012, 8:15:56 PM8/9/12
to hobo...@googlegroups.com
Trying a subdomain enabled site but because most (all?) of the links aren't using url_for, the standard rails way of changing how the subdomain is used no longer works.  Really have a simple case where I want urls to redirect back to the main url when viewing a page through the subdomain, but either I'm too tired to be doing this or it's obfuscated in the source.  Either way, was hoping there'd be a simple one place handles all change to be made.

Bryan Larsen

unread,
Aug 10, 2012, 12:12:23 PM8/10/12
to hobo...@googlegroups.com
That's very strange. I just assumed that we were using the Rails
routing system to build our paths. In many places we are, but the
<a> tag and its helpers build them up as strings, and of course they
don't support the host or protocol options. I'm really surprised
that nobody has complained about that before.

Now I just have to decide whether to refactor object_url to base it on
url_for or whether I should just take the easy route and add host &
protocol options.

Opinions?

Is the app you're working on using 1.4? Whatever I do should
backport fairly easily, but...

Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/RH1hpKLC-SwJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

kevinpfromnm

unread,
Aug 10, 2012, 12:34:41 PM8/10/12
to hobo...@googlegroups.com
No, it's 1.3... though I've thought about moving it forward to 1.4 before we start getting a bunch of users.

The better solution is probably the refactor to use url_for as then you get a single point to make changes that works for both vanilla rails links and hobo links.  Also, since url_for changes to handle subdomains are already documented, it's less documentation to create/maintain.  Either way though, probably need to have the ability to pass host, domain, sub, port etc. options to object_url, even if it just passes it along the chain to url_for.

Another subdomain bug: the url_for_page_path used in table-plus header breaks badly with a subdomain specific route.  I'm routing /:id to a particular controller/method for a particular subdomain and if I leave the table-plus in place, it gives a no route found error (which confused the shit out of me because I thought it was the route that wasn't working for the longest time).

Owen Dall

unread,
Aug 10, 2012, 12:41:40 PM8/10/12
to hobo...@googlegroups.com
Thanks for your input, Kevin.

To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/VlwpP0zxb6IJ.

To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.



--

 

Owen Dall

Vice President | Chief Technology Officer

Barquin International 

www.barquin.com

Office: 202.296.7147 | Mobile: tel:410.991.0811

Fax: 202.296.8903 | email: od...@barquin.com


kevinpfromnm

unread,
Sep 4, 2012, 3:23:42 PM9/4/12
to hobo...@googlegroups.com
Did you end up working this in on 1.4?


On Friday, August 10, 2012 10:12:23 AM UTC-6, Bryan Larsen wrote:

Bryan Larsen

unread,
Sep 4, 2012, 3:43:06 PM9/4/12
to hobo...@googlegroups.com
I'm hoping to push the code for this within the next day or two.

One big side effect of this change is that it messes with named
routes. The new object_url uses polymorphic_url to do all of its
heavy lifting, and polymorphic_url uses named routes behind the
scenes. It assumes that these named routes were generated by Rails
resources mapper. If you were wondering why Hobo 1.3 puts a bunch of
get, put and post statements into hobo_routes.rb rather than a bunch
of resources statements, that's one of the biggest reasons why. Hobo
1.3 names its routes in a manner compatible with Hobo 1.0. Unless we
decide to back out the object_url changes, Hobo 1.4 will create routes
by using "resources" inside of routes.draw. Some of the named routes
will therefore not have the same names as they would in Hobo 1.3.
For example, if you use the function `create_task_for_story_path` in
your code, you would have to change that to `create_story_tasks_path`.
The controller function will still be names
TasksController#create_for_story, but the named path changes.

This will break a lot of people's code, but I think that it's a
worthwhile change -- moving forward we do want to remove incompatible
Hoboisms, this being one of them.

thoughts?

Bryan
> https://groups.google.com/d/msg/hobousers/-/cnU3EjehXqkJ.

kevinpfromnm

unread,
Sep 4, 2012, 4:34:28 PM9/4/12
to hobo...@googlegroups.com
That's a shame.  Seems like 1.0 -> 1.3 would've been the better place to have breaking changes, though maybe spreading the breaks across a couple updates might make it smoother.

If the only downside is that it breaks with previous convention, I'd say let's make the break as otherwise we have to basically duplicate rails efforts in adding equivalent functionality.  It's not just the code maintenance cost, it's also documentation and user confusion as there's no indication as to why changing url_for doesn't affect links.
Reply all
Reply to author
Forward
0 new messages