You can check for a header[X-Requested-With]
to see if it is an AJAX request. Here is a good article on how to do it.
Here is an example:
if request.xhr?
# respond to Ajax request
else
# respond to normal request
end
More Related Contents:
- Rails, Devise authentication, CSRF issue
- Rails 3: How to “redirect_to” in Ajax call?
- How do you handle Rail’s flash with Ajax requests?
- Rails not reloading session on ajax post
- jQuery post to Rails
- Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)
- How to prevent browser page caching in Rails
- ‘sudo gem install’ or ‘gem install’ and gem locations
- ActiveRecord: size vs count
- How to do a LIKE query in Arel and Rails?
- Validate presence of one field or another (XOR)
- Clean way to find ActiveRecord objects by id in the order specified
- Altering the primary key in Rails to be a string
- Rails 4 – passing variable to partial
- Rails: Get Client IP address
- How to get a query string from a URL in Rails
- Rails 3 – select with Include?
- Nokogiri ‘Failed to build gem native extension’ when I run bundle install
- What is the use of Gemfile in rails?
- How do you discover model attributes in Rails?
- Rails 3 equivalent for periodically_call_remote
- Convert HTML to word file ?
- Ruby on Rails 3 – Reload lib directory for each request
- How to edit or write on existing PDF with Ruby?
- How to use long id in Rails applications?
- Why can’t I install the SQLite gem?
- RVM installed by Ruby not working?
- Non persistent ActiveRecord model attributes
- Heroku SSL on root domain
- Rails accepts_nested_attributes_for with f.fields_for and AJAX