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_javasc...
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 I was trying to install RVM for multiuser, There was no proper guidelines for it. So I decided to create one. Please follow the below steps to install RVM for multiuser. 1. Install mpapis public key sudo gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 or curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import 2. Install RVM for Multiuser curl -L https://get.rvm.io | sudo bash -s stable 3. Load RVM to Environment echo "[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm" >> ~/.bashrc source .bashrc 4. Reload shell configuration & test Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command: source /usr/local/rvm/scripts/rvm 5. Final Testing If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command wh...
Comments
Post a Comment