Kaminari pagination with conditions on rails - pagination

i am trying to add conditions to a Kaminari pagination on my rails project and i am finding it almost impossible. here is my code
UserController
#feed=Feed.order('created_at desc').page(params[:page], :conditions=>["source=? or source=?","beep","sub_beep"])
the above didn't work soo i tried the following
#feed1 = Feed.find(:all,:conditions=>["source=? or source=?","beep","sub_beep"])
#feed= Kaminari.paginate_array(#feed1).page(params[:page]).per(2)
the above displays contents but it doesnt display 2 contents per page and the displayed elements arent ordered.
i need a way to add conditions to kaminari pagination and order the result
please i need help!!! :(

Kaminari is designed to work with ActiveRecord 3+ style query interface only.
Please avoid using :conditions "Hasheritis" syntax which will be deprecated sooner or later, but chain with where method instead.
Usage of the where method is well documented here on the Rails Guides: http://guides.rubyonrails.org/active_record_querying.html#conditions
Your controller code should be like this:
feeds = Feed.where(:source => ['beep', 'sub_beep']).order('created_at desc').page(params[:page])

Related

Can we use MatPaginator in Angular without using the MatTableDataSource/<mat-table>?

I am trying to use MatPaginator but with a normal 'table' tag in html instead of 'mat-table'. It didnt seem to work and when I looked up for some references, I found all the examples related to MatPaginator makes use of the MatTableDataSource. Is it compulsory that both should be clubbed and used for the pagination to work?
MatTableDataSource is aimed to be used for filtering, sorting and pagination of a client-side data array. In cases where filtering, sorting and pagination are done server-side, the use of this class is not appropriate.
A good example is given at https://blog.angular-university.io/angular-material-data-table/. It doesn't use MatTableDataSource but still uses mat-table, this should however be easily adaptable to a normal HTML table.

Laravel pagination redirect

I'm using Laravel 4 pagination, and want to remove the page=1 and serve the default string instead; for example:
http://domain.com/search-results/
instead of
http://domain.com/search-results/?page=1
Of course, for page >=2, it's just fine to leave:
http://domain.com/search-results/?page=2
Currently Laravel will always default to showing ?page=1.
Accomplishing what you want (always defaulting to not showing ?page=1) involves a mix of extending/using your own Presenter and/or also by using a custom Pagination view.
Stock pagination views are here, but you can create your own and define it within the view.php config.
In my blog, I do similar. My pagination view is here. You can see it loads in a custom Presenter class.
Note that my blog may not be up to date with latest Laravel code, but that should get you on your way to making the edits you need to do to accomplish that.
You may be able to skip code altogether and use a server configuration to redirect - That link assumes Apache.

Drupal 7 Partial Search

Is there a way make Drupal's search module work on partial search? For example I want to find a node which has title like "apple" when I search "app". I made a research, there are some modules. Fuzzy Search module is useful for me but it does not work.
Regards
You can do it with hook_query_alter, hook triggered before running on db , all sql statements are entering to this hook. You can modify the query as you want. But it can be a little bit difficult. Because there is 3 query you have to modify. Main search query is third one. But 2nd and 3td one are working if first query has a result. Therefore you can be confused a little bit when you are working on it. If you can't resolve the problem, write me I will send you a code block.

Putting islandora results in a view or block

I am new to islandora. I have it integrated with solr and it works fine but the results only show on the page with the following URL:
somesite.com/islandora/search
This is fine but I would like the results to show on a different page inside a view or a block.
Is this actually possible?
After reading the documentation it doesn't seem like it is. But I believe this should be a rather slandered requirement.
I have tried using URL Aliases, with no luck.
Has anyone done this??
If you have integrated the apache solr with sit Search then there is a module named Search API Page Block, which can help you showing result in block but it will only work for title of the nodes.
As it explains -
Currently, this module is only useful when placing search result
blocks on node pages, since it currently only uses $node->title as the
search keywords. Future development can lead to other uses, including
using Taxonomy terms, Context module, or custom fields to set the
keywords.

What's a good node.js / mongoose form builder?

From using other frameworks I've gotten used to not building out and mapping forms to db objects manually. Since using node.js and mongoose. I'm looking for a form builder that allows the following:
automatically maps mongoose objects to form fields
handles both 'new' and 'update' use cases
allows class injection around form fields for styling
includes validation
allows one to add custom fields
Does anyone know of any such form builders for node.js, express, mongoose?
I haven't used it, or looked at it in depth, but https://github.com/oJshua/mongoose-forms looks like it may be of interest.
I know this is kind of old discussion but I just wanted to recommend checking out Formage (npm: formage)
https://github.com/Empeeric/formage
Setup is easy and straightforward. You can check it out in matter of minutes and hopefully this can help you.

Resources