Hello, I accidentally posted this to the "Ruby" forum when it should have gone here -- sorry. I am using *_path in views and *_url in controllers (with redirect_to, for example). It is my understanding that this is generally considered a good practice. I want to use my app using https, and thought it would work that way as long as I loaded the app by browsing to https://my.app.com. However, it appears that even if I do this, redirect_to some_model_url generates a url with a protocol of https://. How do I get *_url to generate a url with https:// for the protocol? Regards, Errol -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-May-27 16:46 UTC
Re: How to have *_url generate urls with https:// protocol
> Hello, > > I accidentally posted this to the "Ruby" forum when it should have gone > here -- sorry. > > I am using *_path in views and *_url in controllers (with redirect_to, > for example). It is my understanding that this is generally considered > a good practice. > > I want to use my app using https, and thought it would work that way as > long as I loaded the app by browsing to https://my.app.com. However, it > appears that even if I do this, redirect_to some_model_url generates a > url with a protocol of https://.I assume you meant to say "http://" ?> How do I get *_url to generate a url with https:// for the protocol?some_model_url(:scheme => ''https'') -philip -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Errol Siegel
2010-May-27 17:11 UTC
Re: How to have *_url generate urls with https:// protocol
> I assume you meant to say "http://" ?Yes! I thought I proof-read so well...>> How do I get *_url to generate a url with https:// for the protocol? > > some_model_url(:scheme => ''https'') >Thanks for the response. I guess I was looking for a way to do this application-wide. It would not be very DRY to have to add (:scheme => ''https'') to every place in my app where I call a *_url helper. Is there another way? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-May-27 17:33 UTC
Re: Re: How to have *_url generate urls with https:// protocol
On May 27, 2010, at 10:11 AM, Errol Siegel wrote:>> I assume you meant to say "http://" ? > > Yes! I thought I proof-read so well... > >>> How do I get *_url to generate a url with https:// for the protocol? >> >> some_model_url(:scheme => ''https'') >> > Thanks for the response. I guess I was looking for a way to do this > application-wide. It would not be very DRY to have to add (:scheme => > ''https'') to every place in my app where I call a *_url helper. > > Is there another way?Use *_path? I do it and haven''t seen any browsers complain about the redirects... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Errol Siegel
2010-May-27 18:35 UTC
Re: Re: How to have *_url generate urls with https:// protocol
> Use *_path? I do it and haven''t seen any browsers complain about the > redirects...Again, that would mean going through the entire application and changing every reference. Besides, using relative paths in redirects violates the HTTP spec. I understand that it gets the job done, but that doesn''t seem like the right way to do it. I don''t wish to appear argumentative, but I really hope somebody knows a cleaner way to do this. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-May-27 21:36 UTC
Re: Re: How to have *_url generate urls with https:// proto
Errol Siegel wrote:>> Use *_path? I do it and haven''t seen any browsers complain about the >> redirects... > Again, that would mean going through the entire application and changing > every reference. > > Besides, using relative paths in redirects violates the HTTP spec. I > understand that it gets the job done, but that doesn''t seem like the > right way to do it. > > I don''t wish to appear argumentative, but I really hope somebody knows a > cleaner way to do this.Use default_url_options. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Errol, If you want to pull out data in csv format from an existing mysql database using Rails, this is the easiest way to do it : 1. install fastercsv : sudo gem install fastercsv 2. Add on top of your controller : require ''fastercsv'' 3. Create an action in your controller and its corresponding view # The action def import_csv result = YourModel.find(:all, :conditions => "your_condition") @outfile = "your_csv_report_name_" + Time.now.strftime("%m-%d-%Y") + ".csv" csv_data = FasterCSV.generate do |csv| #field names csv << ["Field_name_1"] csv << ["Field_name_2"] #Data result.each do |table| csv << [ table.field1 table.field2] end #Write data in csv format send_data csv_data, :type => ''text/csv; charset=iso-8859-1; header=present'', :disposition => "attachment; filename=#{@outfile}" redirect_to :action => "your_action" end end #The view <% form_tag :action => "import_csv" do %> <%= submit_tag ''Import CSV'' %> <% end %> Hope this helps! Regards, On May 27, 11:36 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Errol Siegel wrote: > >> Use *_path? I do it and haven''t seen any browsers complain about the > >> redirects... > > Again, that would mean going through the entire application and changing > > every reference. > > > Besides, using relative paths in redirects violates the HTTP spec. I > > understand that it gets the job done, but that doesn''t seem like the > > right way to do it. > > > I don''t wish to appear argumentative, but I really hope somebody knows a > > cleaner way to do this. > > Use default_url_options. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.