help: ActionController::UnknownFormat in FooController#index

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

help: ActionController::UnknownFormat in FooController#index

tommaso159
HI,

i have a couple of 'seo' routes, which are not responding well

eg:
  match  'whatever/in/:seoterm'       , as: 'seo_whatever _in'  , :to => 'foos#index', via: [:get]  , :mode=>{:x=>' whatever ',:y=>1}


 respond_to do |format|
    format.html { 
      }
    format.js {
    }
    format.json {
        render :json =>  JSON::parse({:list => @.... }
    }
   # format.xml  { 
        #render xml: @person.to_xml(include: @company) 
       # render xml: @commutes.to_xml #(include: @company) 
    #  }
  end


--> the only thing  i see is that the brwoser comes as */* , which shouldnt be the problem:
Started GET "/whatever/in/St.%20Peters" for 10.0.1.37 at 2018-03-05 12:09:39 -0500
Processing by FooController#index as


any ideas?

thx

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMftMvUp2tCHZJm1vQwEv09G10wHoX24DVxxo8gntEQoHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

Hassan Schroeder-2
On Mon, Mar 5, 2018 at 9:13 AM, tom <[hidden email]> wrote:

> i have a couple of 'seo' routes, which are not responding well

What does that mean?

( http://www.catb.org/esr/faqs/smart-questions.html )

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yC_xOFmo%2BZtxBi1Rr%3DLVhzFWYnjVbmG_TSZTAhyNx3mDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

tommaso159
getting 406 due to rails giving me ActionController::UnknownFormat
and i dont know why.

same routes(pattern) in a different controller work just fine. only difference is that the other one only does render, not repsond_to


On Mon, Mar 5, 2018 at 12:29 PM, Hassan Schroeder <[hidden email]> wrote:
On Mon, Mar 5, 2018 at 9:13 AM, tom <[hidden email]> wrote:

> i have a couple of 'seo' routes, which are not responding well

What does that mean?

( http://www.catb.org/esr/faqs/smart-questions.html )

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yC_xOFmo%2BZtxBi1Rr%3DLVhzFWYnjVbmG_TSZTAhyNx3mDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMcoqnDDRHVUh0nPEPum%3DSSUqqNZS64Ud65ShT3u_gYwSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

Hassan Schroeder-2
On Mon, Mar 5, 2018 at 9:33 AM, tom <[hidden email]> wrote:
> getting 406 due to rails giving me ActionController::UnknownFormat
> and i dont know why.

Maybe because GET "/whatever/in/St.%20Peters" provides no
information about the requested response format?

> same routes(pattern) in a different controller work just fine. only
> difference is that the other one only does render, not repsond_to

I'd think that would be a good clue...

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDoYipL%3DSbWVspDwgaXTouEdYeUZhsk1hXm6wYnO%3DGC1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

tommaso159
so how can i pass this along? why is it not assuming html?


On Mon, Mar 5, 2018 at 12:53 PM, Hassan Schroeder <[hidden email]> wrote:
On Mon, Mar 5, 2018 at 9:33 AM, tom <[hidden email]> wrote:
> getting 406 due to rails giving me ActionController::UnknownFormat
> and i dont know why.

Maybe because GET "/whatever/in/St.%20Peters" provides no
information about the requested response format?

> same routes(pattern) in a different controller work just fine. only
> difference is that the other one only does render, not repsond_to

I'd think that would be a good clue...

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDoYipL%3DSbWVspDwgaXTouEdYeUZhsk1hXm6wYnO%3DGC1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMfGzhwm7bZUzzE5xeu%3Dg5-5MkuGaD96sLiHtHq70SYy7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

Hassan Schroeder-2
On Mon, Mar 5, 2018 at 9:59 AM, tom <[hidden email]> wrote:
> so how can i pass this along? why is it not assuming html?

Because computers don't make assumptions?  😀

Why are you telling it to respond differently depending on the format
and then *not providing a format*??

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBD%2Bv22VHM4CK3%3D2EpfH3qQ%2BYPOMVQuJmx1DNO0kN2vfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

tommaso159
, :defaults => { :format => 'html' } 
fixed it
thank you


On Mon, Mar 5, 2018 at 1:15 PM, Hassan Schroeder <[hidden email]> wrote:
On Mon, Mar 5, 2018 at 9:59 AM, tom <[hidden email]> wrote:
> so how can i pass this along? why is it not assuming html?

Because computers don't make assumptions?  😀

Why are you telling it to respond differently depending on the format
and then *not providing a format*??

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBD%2Bv22VHM4CK3%3D2EpfH3qQ%2BYPOMVQuJmx1DNO0kN2vfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMe_JEONtq2zgEM2W5biK%3Dx0AOD8Y2Mwm-sMhXiTCkRo_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

Hassan Schroeder-2
On Mon, Mar 5, 2018 at 10:27 AM, tom <[hidden email]> wrote:
>
> , :defaults => { :format => 'html' }
> fixed it

Awesome!

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAB%2BiGh5UC001k0vJv0mVaADzYJhokqjpiAX-%2Bbo7tVfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

Rob Biedenharn-3
In reply to this post by Hassan Schroeder-2


On 2018-Mar-5, at 13:15 , Hassan Schroeder <[hidden email]> wrote:

On Mon, Mar 5, 2018 at 9:59 AM, tom <[hidden email]> wrote:
so how can i pass this along? why is it not assuming html?

Because computers don't make assumptions?  😀

Why are you telling it to respond differently depending on the format
and then *not providing a format*??

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

> Started GET "/whatever/in/St.%20Peters" for 10.0.1.37 at 2018-03-05 12:09:39 -0500
> Processing by FooController#index as

You really should have added one more line from the log here.

It was very likely looking for a :format => '%20Peters" because of the '.' in the URL path.

Look at the output from `rails routes` to see the various ways that you might be routing to foos#index

Another way to fix this tends to "break" having multiple formats. You can add:

> eg:
>   match  'whatever/in/:seoterm'       , as: 'seo_whatever _in'  , :to => 'foos#index', via: [:get]  , :mode=>{:x=>' whatever ',:y=>1}

, constraints: { seoterm: /.+/ }

so that :seoterm slurps all the remaining characters of the URL. This breaks the "implicit" (.:format) that gets added because the constraint will match the '.' and everything after it leaving nothing to match the "optional" format.

-Rob

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/45979B90-B83A-4EB9-9770-7E2C222E0620%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help: ActionController::UnknownFormat in FooController#index

tommaso159
you are correct. the space and or the period was the problem here.

ill try out different solutions now

thx all!


On Mon, Mar 5, 2018 at 2:15 PM, Rob Biedenharn <[hidden email]> wrote:


On 2018-Mar-5, at 13:15 , Hassan Schroeder <[hidden email]> wrote:

On Mon, Mar 5, 2018 at 9:59 AM, tom <[hidden email]> wrote:
so how can i pass this along? why is it not assuming html?

Because computers don't make assumptions?  😀

Why are you telling it to respond differently depending on the format
and then *not providing a format*??

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

> Started GET "/whatever/in/St.%20Peters" for 10.0.1.37 at 2018-03-05 12:09:39 -0500
> Processing by FooController#index as

You really should have added one more line from the log here.

It was very likely looking for a :format => '%20Peters" because of the '.' in the URL path.

Look at the output from `rails routes` to see the various ways that you might be routing to foos#index

Another way to fix this tends to "break" having multiple formats. You can add:

> eg:
>   match  'whatever/in/:seoterm'       , as: 'seo_whatever _in'  , :to => 'foos#index', via: [:get]  , :mode=>{:x=>' whatever ',:y=>1}

, constraints: { seoterm: /.+/ }

so that :seoterm slurps all the remaining characters of the URL. This breaks the "implicit" (.:format) that gets added because the constraint will match the '.' and everything after it leaving nothing to match the "optional" format.

-Rob

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/45979B90-B83A-4EB9-9770-7E2C222E0620%40gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMfcOW%3DxcUT1hZrqH_0p6qPdo%2BjiNpDxJNOPuBTaXeyF3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.