Posts

Showing posts with the label active admin

Create worker in rails by sidekiq and redis

Add sidekiq to your Gemfile: Add this to your Gemfile gem 'sidekiq' Run bundle install bundle install Create worker rails g sidekiq:worker Test #will create app/workers/test_worker.rb class TestWorker   include Sidekiq::Worker   def perform(id, name)     # do something   end end Call worker without any time boundation TestWorker.perform_async(5, 'rahul') //use this anywhere from your rails app(controller, model, helpers..) Call worker within particular time period TestWorker.perform_in(5.minutes, 5, 'rahul')  //use this anywhere from your rails app(controller, model, helpers..) Call worker after specific time interval once only TestWorker.perform_at(5.minutes.from_now, 5, 'rahul')  //use this anywhere from your rails app(controller, model, helpers..) Start sidekiq on development bundle exec sidekiq Start sidekiq on production bundle exec sidekiq -d //run this first if you get some error then use second one bundle exec si

How to customise active admin page on keypress

Image
How to customise active admin page on keypress First make new route for getting filtered data: get '/admin/gyms/search_user', :to => 'admin/gyms#search_user', as: :search_gym_user In your controller create new method def search_user      @user =  User.where("name = ? AND role = ?", params[:name], "none") if params[:name].present?      respond_to do |format|        format.json  { render :json => @user }      end    end Render partial and add a id to to table panel "Gym Users:", :id => "foo-panel" do      # renders app/views/admin/posts/_search_users.html.erb       render 'search_users', { users: gym.users }      table_for gym.users, id: "search_gym_user" do        # binding.pry        # filter :"name" , :as => :select, :collection => gym.users.pluck(:name)        column "Joined" do |user|          distance_of_time_in_words(user.created_at, Time.now)    

Make admin panel with Active admin rails || active_admin rails

Image
Make admin panel with Active admin rails || active_admin rails  Open Terminal and copy and paste this Command rails new admin_example // creating new rails application go inside the project cd admin_example run bundle install bundle install open your gem file and add this new gem's gem 'activeadmin' / / for active admin panel gem 'inherited_resources' //  making your controllers inherit all restful actions gem 'devise' // for user authentication  run bundle install again bundle install install active admin rails g active_admin:install / /install active admin to your project migrate database rake db:migrate check your seed file and run rake db:seed create user file and model rails g User name email  create post file and model rails g Post title body:text published_at:datetime user:references Now Migrate DataBase rake db:migrate start rails server rails s Hit url localhost:3000/admin/login Enter login details you can find login