Sunday, July 10, 2011

[Rails] Rails 3 routing errors - how to remove "?format=" so no more 406 Not Acceptable responses?

I haven't been able to find an answer yet, and unfortunately I can't
find anything useful in the API docs to fix this...

I scaffolded exercise_model, but I want all the URLs to be /exercise/*
That means changing
form_for @exercise_model
into what? I already have this entry in routes:
post 'create_exercise' => 'exercise_models#create'


A. form_for @exercise_model, :url =>
create_exercise(@exercise_model)

That fails on the submit because action="/exercise/create?format="
makes Rails respond with "Completed 406 Not Acceptable"

B. form_for @exercise_model, :as => :exercise

Fails to render the page because there is no class Exercise.
And all 3 of these give the very same URL as #1 above:

C. form_for @exercise_model, :url =>
create_exercise(@exercise_model), :format => :html

D. form_for @exercise_model, :url =>
create_exercise(@exercise_model,:format)

E. or in routes.rb, making it
constraints :format => "html" do
create_exercise => "exercise_models#create"
end

What's the trick, or can't Rails do this?

--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate