1. Install Paginator
C:\prj4rails\rnd>gem install paginator
Fetching: paginator-1.2.0.gem (100%)
Successfully installed paginator-1.2.0
Parsing documentation for paginator-1.2.0
Installing ri documentation for paginator-1.2.0
Done installing documentation for paginator after 2 seconds
1 gem installed
INSTALL
- Download from GitHub and unzip into vendor/plugins. (Rails 5 : Add Gem "record_select" in gem file)
- Enable and configure it on a controller.
class UsersController < ApplicationController
record_select :per_page => 5, :search_on => 'username'
end
1. Optional: to use RecordSelect RESTfully, add the following to your routes.rb:map.resources :model_id, :collection => {:browse => :get}, :member => {:select => :post}
1. Now go ahead and use it somewhere.
HOWTO
Let's assume that you have two models, NewsArticles and Authors, and every NewsArticle belongs_to :author.
Let's assume that your goal is to set up the scaffold for NewsArticles so that the create/update forms use RecordSelect to pick the appropriate Author. To accomplish this using the default intelligence of these two plugins, you need to do two things:
- Configure RecordSelect on the AuthorsController.
- Configure the NewsArticles scaffold with
config.columns[:author].form_ui = :record_select
. - If you want to use both RESTfully, combine the configuration in your routes.rb:
map.resources :news, :active_scaffold => true, :collection => {:browse => :get}, :member => {:select => :post}
It's important to understand that the relationship between the two models is mirrored between the two controllers. The NewsArticlesController will display a form that calls RecordSelect via
but README in github is not updated either
Do not change your layout, don't add record_select_includes, it doesn't exist
anymore because current way is adding //= require record_select to asset
manifest.
/authors/browse
. If you want to customize which authors are returned in the result set (e.g. change the number of authors per-page), you need to configure RecordSelect on the AuthorsController.Advice from Sergio Cambra
1. You are reading a really old web, recordselect is not in google code anymore,but README in github is not updated either
Do not change your layout, don't add record_select_includes, it doesn't exist
anymore because current way is adding //= require record_select to asset
manifest.
Anyway, you don't have to add anything else to your application
manifest, ActiveScaffold already includes record_select to assets through
record_select bridge when recordselect gem is installed.
Q2. ActionView::Template::Error (No route matches {:*action=>"browse"*,
A2
Add record_select_routes to your resources routes:
Q3. But its shows as Root Cause:FEATURE, how can I make as FEATURE ?
A3
It uses to_label method in your model, as ActiveScaffold, you can change to_label method in your model. Or setup recordselect to use different method or partial:
manifest, ActiveScaffold already includes record_select to assets through
record_select bridge when recordselect gem is installed.
Q2. ActionView::Template::Error (No route matches {:*action=>"browse"*,
A2
Add record_select_routes to your resources routes:
resources :rootcauses do
record_select_routes
concerns :active_scaffold
end
It will define get browse route on collection
Q3. But its shows as Root Cause:FEATURE, how can I make as FEATURE ?
A3
It uses to_label method in your model, as ActiveScaffold, you can change to_label method in your model. Or setup recordselect to use different method or partial:
Here is some old doc, still applies:
In summary, you can use partials, and set partial name with :label option:
record_select ..., :label => 'partial name'
Or use a proc or lambda:
No comments:
Post a Comment