Here is a simple way to implement AJAX pagination using Kaminari gem. Suppose, We are having a Product Model with fields id and name. So, In the ProductsController , def index @products = Product.all.page(params[:page]).per(params[:per]) respond_to do |format| format.js format.html end end in view file index.html.haml #products = render 'products' #paginator = paginate @products, :remote => true And create _products.html.haml (this will be rendered from index) with content %table @products.each do |product| %tr %td= product.name Finally, We have to create one more file _index.js.haml with content $('#products').html("#{escape_javascript(render 'products')}"); $('#paginator').html("#{escape_javascript(paginate(@products, :remote => true)) }"); This post may help you. Please comment on the same, If you guys have any queries.
This can be done only with a custom method validation, Such as class Comment include Mongoid::Document include Mongoid::Timestamps include ActiveModel::Validations validate :must_be_friends def must_be_friends errors.add(:base, 'Must be friends to leave a comment') if hash[:firstname].nil? end end
When changing Rails versions, it's best to move slowly, one minor version at a time The process should go as follows: Write tests and make sure they pass. Move to the latest patch version after your current version. Fix tests and deprecated features. Move to the latest patch version of the next minor version. Repeat this process until you reach your target Rails version Rails 6 requires Ruby 2.5.0 or newer. Rails 5 requires Ruby 2.2.2 or newer. Rails 4 prefers Ruby 2.0 and requires 1.9.3 or newer. Rails 3.2.x is the last branch to support Ruby 1.8.7. Rails 3 and above require Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially. You should upgrade as early as possible. Rails provides the app:update command ( rake rails:update on 4.2 and earlier). After updating the Rails version in the Gemfile , run this command. This will help you with the creation of new files and changes of old files in an interactive session.
Comments
Post a Comment