Potresti dirmi come disabilitare le opzioni.: Format in rails route? Ho solo bisogno di html ...Disabilita: .format route in rails3
risposta
In 3.1.1 almeno è possibile aggiungere, :format => false
alla fine del percorso.
trovate qui: http://guides.rubyonrails.org/routing.html#request-based-constraints ai sensi dell'articolo 3.11 percorso Globbing
ad es ..
match '*pages' => 'pages#show', :format => false
che consentirebbe params [: Pagine] per includere un periodo.
http://guides.rubyonrails.org/routing.html#request-based-constraints
Questo sarà limitare i percorsi per accettare solo formato html:
constraints :format => "html" do
resources :posts do
resources :comments
end
end
Tuttavia, non rimuoverà (.:format)
parte dal rake routes
uscita.
So di essere in ritardo, ma con le rotaie 3.2.13 Questo fa sì che le richieste provenienti da curl per rendere un errore 404, e la mia il sito web è stato completamente cancellato da google ... – Intrepidd
Se si desidera gli URL e non piace :format => false
si potrebbe provare questo:
# :format must match the empty string
constraints :format => // do
resources :monkeys
end
Anche utilizzando with_options
, l'opzione :format => false
è ingombrante, soprattutto se si hanno un sacco di percorsi.
Puoi avvolgere si aggira un ambito (Rails 4):
scope format: false do
# your routes here
end
esattamente quello che stavo cercando, grazie mille! Btw, anche in Rails 5. –
- 1. Rails3 hidden_field in haml
- 2. UUID in Rails3
- 3. "% s"% format vs "{0}". Format() vs "?" Formato
- 4. Crontab + rails3 + bundler
- 5. Rails3 e Paperclip
- 6. rails3 gem: act_as_something
- 7. _NT_SYMBOL_PATH format
- 8. Debugging route in codeigniter?
- 9. Utilizza una route come alias per un'altra route in Express.js
- 10. Precisione variabile in d3.format
- 11. numeri Format tooltip in Highcharts
- 12. hapi.js - 404 route VS file statici route
- 13. Laravel - Route :: resource vs Route :: controller
- 14. Come personalizzare il metodo to_json in rails3?
- 15. non può modificare Hash congelato in Rails3
- 16. Soluzioni per cron jobs in rails3
- 17. Utilizzo del metodo .where in Rails3
- 18. Utilizzo di paperclip gem in rails3
- 19. Rails 3 Problemi di root route?
- 20. Reshape Panel Data Wide Format to Long Format
- 21. Cosa significa (.: Formato) nell'output di rake route?
- 22. Interpolazione in Rails Route Helper
- 23. Angular2 - Route mockingParams in prova
- 24. ASP.NET MVC: Namespaces in route
- 25. Rails3: combinare portata con OR
- 26. Py Pandas .format (dataframe)
- 27. python .format() campi ripetuti?
- 28. TimeSpan.Parse time format hhmmss
- 29. funzione ".format" di python
- 30. md-datepicker input format
sì, molto più bello della risposta accettata –