我正在处理rails 4
,这是我的步骤: -
gem kaminari
--in gemfile @vendors = Vendor.order(:name).page params[:page]
vendor_controller.rb)
还试过@vendors=Vendor.order("name").page(params[:page]).per(5)
<% = paginate @vendors %>
中index.html.erb
醇>
错误: -
undefined method `page' for #<ActiveRecord::Relation::ActiveRecord_Relation_Vendor:0x16bec10>
我也试过console
Vendor.count
a = Vendor.limit(5).count
b = a.page(1).per(20).size
错误: -
NOmethoderror undefined method 'page'
问题: - 哪里出错了??
由于
答案 0 :(得分:0)
尝试直接从ActiveRecord
类调用页面方法。您在订单后调用它,返回ActiveRecord::Relation
个对象。
@vendors = Vendor.page(params[:page]).order(:name)
答案 1 :(得分:0)
我认为这可以解决您的问题:
private void createHotspot2() {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = "MyDummySSID";
wifiConfiguration.preSharedKey = "abcdefgh123";
wifiConfiguration.status = WifiConfiguration.Status.ENABLED;
wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
try {
Method method = wifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class,
boolean.class);
method.invoke(wifiManager, wifiConfiguration, true);
} catch (Exception e) {
e.printStackTrace();
}
}
在模型中使用:
vendor.except(:limit, :offset)