funs短文
@funs = Fun.where( "taggings.tag_id = #{params[:tag_id].to_i}").joins(" right join taggings on funs.id = taggable_id").paginate(:page => params[:page], :per_page => 10, :include => :user, :readonly => false).order ( 'funs.created_at DESC')
This might have changed in recent release of Rails, but the appropriate way to solve this problem is to add :readonly => false to the find options.
Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around.
Using find_by_sql
is not really an alternative as it returns raw row/column data, notActiveRecords
. You have two options:
- Force the instance variable
@readonly
to false in the record (hack)
- Use
:include => :card
instead of :join => :card
def join_tags(post)
post.tags.map { |t| t.name }.join(", ")
end
分享到:
相关推荐
Api-laravel-json-api-paginate.zip,一个很好地处理json api规范的分页器一个很好地处理json api规范的分页器,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库通信。...
前端项目-vuejs-paginate,Vue.js的简单分页组件
Laravel开发-laravel-paginate-plus Laravel的额外分页函数
前端项目-vue-paginate,对数据分页的简单Vue.js插件
安装您可以通过composer安装该软件包: composer require spatie/laravel-json-api-paginate 在Laravel 5.5及更高版本中,服务提供商将自动注册。 在旧版本的框架中,只需在config/app.php文件中添加服务提供者: '...
$ yarn add nestjs-typeorm-paginate 要么 $ npm i nestjs-typeorm-paginate 用法 服务 存储库 import { Injectable } from '@nestjs/common' ; import { Repository } from 'typeorm' ; import { ...
猫鼬-聚集-分页mongoose-aggregate-paginate是一个插件,易于为聚合添加分页。 该插件可以与视图分页中间件(例如结合使用。指数安装npm install mongoose-aggregate-paginate --save用法必须首先将此插件添加到架构...
MongoDb / Mongoose 分页正确完成 使用范围分页的实用函数,比使用skip()快得多。 安装 $ npm install mongoose-range-paginate 例子 var paginate = require ( 'mongoose-range-paginate' ) ... where ( { tag
烧瓶其余分页 Flask RESTful的分页扩展。... config [ 'SQLALCHEMY_DATABASE_URI' ] = "sqlite:///paginate-test.db" db = SQLAlchemy ( app ) pagination = Pagination ( app , db ) 在您的项目中用作 pag
node-mysql-paginate是一个库很容易地添加分页查询和结果。 这个库的灵感来自库的工作。 指数 安装 npm install -S niltonvasques/node-mysql-paginate 用法 var paginate = require ( 'node-mysql-paginate' ) ; ...
$ npm install mongoose-ranged-paginate 用法 要从1cdfb22e1f3c000000003152开始获取20个1cdfb22e1f3c000000003152 , require ( 'mongoose-ranged-paginate' ) MyModel . find ( ) . sort ( '-_id' ) . ...
paginate(每页数量,是否简洁分页,分页参数) 使用方式 $list = db('user')->paginate(10); 自定义参数传参 $list = db('user')->paginate(10,false,['query'=>array('id' => $id)]); 其它参数 // 总数据 $this->...
npm install mongoose-aggregate-paginate-v2 用法 将插件添加到架构, var mongoose = require ( 'mongoose' ) ; var aggregatePaginate = require ( 'mongoose-aggregate-paginate-v2' ) ; var mySchema = new ...
通过NPM安装npm install --save vue-paginate-al注册为插件从'vue'导入Vue从'vue-paginate-al'导入VuePaginateAl Vue.component('vue-paginate-al',VuePaginateAl)用法 //示例1 //示例2 =>具有背景色
资源分类:Python库 所属语言:Python 资源全名:flask-paginate-0.2.8.zip 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
npm i --save gatsby-plugin-paginate 配置 插入 在您的gatsby-config.js : module . exports = { plugins : [ ... { resolve : `gatsby-plugin-paginate` , options : { sources : [ { path : `/page` ,...
will_paginate-bootstrap, 将 Twitter Bootstrap 分页组件与will_paginate集成 will_paginate-bootstrap不再维护我不再使用 Bootstrap 来使用 Rails,所以不幸的是,我不再接受请求请求或者维护这个库。 为了发布你...
利用Horse-Paginate (delphi中间件)做分页 -源码
npm install mongoose-paginate-pages 用法 var paginate = require ( 'mongoose-paginate-pages' ) ; Schema . plugin ( paginate ) ; Model . paginate ( query , options , function ( err , results , total , ...
jQuery paginate分页导航插件ajax分页代码 jQuery paginate分页导航插件ajax分页代码 jQuery paginate分页导航插件ajax分页代码