Hi Ignacio;

We can put out the fire. I discovered that the host does *not* have to 
appear in the *action* parameter for Ajax routes. 

In my case, hosting in a subdirectory, required me to add ":path_only => 
false" and ":script_name => [name of subdirectory]" to my 
default_url_options. 

So, I've ended up with this definition in one of my environment files:

default_url_options = { :host => 'server.com', :protocol => "https", :port 
=> nil, *:only_path => false*, *:script_name => '/app/lts-stb'* }

It's an obscure setting, but has done the trick. My generated *action* 
parameter 
on a form now appears correctly as:

form action="/app/lts-test/instruments/387438/add_other_related_instrument"


Thanks to your hint and to this article:
http://www.stormconsultancy.co.uk/blog/development/code-snippets/actionmailer-link-for-a-rails-app-deployed-in-a-sub-directory/

Tim



On Saturday, June 4, 2016 at 11:55:15 PM UTC-4, Tim Griffin wrote:
>
> Thanks so much, Ignacio... I'll give it a whirl and report back. It might 
> just cover me for now. 
>
> Much, much appreciated!
> Tim
>
>
> On Saturday, June 4, 2016 at 4:36:17 PM UTC-4, Ignacio Huerta wrote:
>>
>> Hi Tim,
>>
>> It seems like Hobo is ignoring your default url options.
>>
>> Please try this workaround, I think it should help:
>>
>>
>> * Clone the Hobo repository
>> * Point your Gemfile to the cloned folder: gem 'hobo', path: 
>> '/my/path/hobo'
>> * Edit hobo/app/helpers/hobo_route_helper.rb:72, and replace the 
>> "polymorphic_path" call with this:
>>         params[:host] = "mydomain.com"
>>         base_url = url = polymorphic_url(poly, params)
>> * Run bundle, and restart your app
>>
>>
>> If it works, maybe you can try to implement some logic to look for the 
>> existence of default_url_options[:host]. I made a quick try but it looks 
>> like "default_url_options" was not available.
>>
>> Warm regards,
>> Ignacio
>>
>>
>>
>>
>> On Friday, June 3, 2016 at 1:20:11 AM UTC+2, Tim Griffin wrote:
>>>
>>> Hi all;
>>>
>>> Anyone have any bright insight in how to get Hobo-generated ajax routes 
>>> to include the host (and port)? 
>>>
>>> I have this definition:
>>>
>>> <form 
>>> with="&new_for_current_user(this.document_attachments)" 
>>> owner="document" 
>>> message="Uploading..." 
>>> updates="#attachments-div,#document-requirements-div" 
>>> without-cancel>
>>>
>>> for which Hobo generates a relative path for the action:
>>>
>>> <form action="*/documents/4228/document_attachments*"...
>>>
>>> and I really need this:
>>>
>>> <form action="*https://server.com/lts <https://server.com/lts>*
>>> /documents/4228/document_attachments"...
>>>
>>> I already have default_url_options set in my ApplicationController:
>>>
>>>   def default_url_options(options={})
>>>       case Rails.env.to_sym
>>>       when :development
>>>         { :host => 'localhost', :port => request.port }
>>>       when :test
>>>         { :host => 'localhost', :port => request.port }
>>>       when :staging
>>>         {:host => "testserver.com"}
>>>       when :production
>>>         {:host => "server.com"}
>>>       end
>>>
>>> but, my guess is that this is not consulted when Hobo generates an ajax 
>>> route. 
>>>
>>> Hobo generates relative routes for all of its ajax links that it 
>>> creates... so, anything I can do? 
>>>
>>> If I wasn't being asked to host this app in a sub-directory, I wouldn't 
>>> worry about it, but....
>>>
>>> Many thanks,
>>> Tim
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to