Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

active admin with friendly_id

  # app/admin/group.rb

  # find record with slug(friendly_id)
  controller do
    def find_resource
      begin
        scoped_collection.where(slug: params[:id]).first!
      rescue ActiveRecord::RecordNotFound
        scoped_collection.find(params[:id])
      end
    end
  end
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby select certain keys from hash 
Ruby :: format date rails created long 
Ruby :: ruby refinement include module 
Ruby :: how to differentiate get and post when it has same name in rails 
Ruby :: ruby loop over files in a folder 
Ruby :: rails automatically downcase on create 
Ruby :: rails if else assignment one liner 
Ruby :: ruby on rails array contains multiple values 
Ruby :: ruby delete method 
Ruby :: rails migration populate data 
Ruby :: check if the substring is present in the column of the record rails console 
Ruby :: ruby on rails 4.2 how to add GET route 
Ruby :: rails rspec destroy data after each test 
Ruby :: my rails server exits automatically and now gives the following error: 
Ruby :: pick element from array that is part of params hash 
Ruby :: how do i fix FATAL: password authentication failed for user "root" 
Ruby :: include? reverse ruby 
Ruby :: ruby find lower number array object 
Ruby :: Range extraction: convert a comma separated list of integers into range format 
Ruby :: record count by month in rails 
Ruby :: get directory of current file ruby 
R :: Drop rows with missing values in R 
R :: collapse text by group in dataframe r 
R :: merge multiple datatable in r 
R :: rename column in r 
R :: switch in r 
R :: create a table from dataframe in r 
R :: r matrix 
R :: make gif r 
R :: r for loop 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =