What are rails smart collections?
If I am trying to build a view that presents most popular articles, top 10 products, recent comments (i.e a snapshot of recent updates to a variety of models in one view), would I be using a smart collection?
Would I be updating it via something like delayed job? Use some sort of fragment caching?
What's the best way of doing this?
Thanks
I've never heard of 'smart collections'. That reference to them in the delayed_jobs docs seems to be the only one out there. It would probably be better to email the author, he might have been referring to something that exists only in his head :)
Related
I am trying to add some chronology to my 'jobs' so that when someone posts a job it lists conveniently under the date in which it was created and other posts will then go above it based on recency. An example of this can be seen on Dribble Jobs.
I am not really sure how to best approach this as it is something I haven't done before, any suggestions on how to achieve it would be much appreciated!
You can use Rails timestamps, which will make this very, very easy. Just use the created_at timestamp for the jobs, and order by that (or perhaps the id field).
I'm looking for a Rails plugin that facilitates showing lists of objects. Ideally I'd like to pass an ActiveRecord query and get a table that shows a result of this query. The table should be sortable, paginated and searchable (using some kind of filters).
I've already found two that might be ok. The first is DataGrid. It looks fine, but it uses will-paginate and as I adopted kaminari in the project, I'm not sure if such mixing would be a good idea.
FancyGrid looks tempting, but it seems to be not maintained and so I'm not sure, if it's good idea to use it.
Do you know anything more?
There's a railscasts that may be relevant. See here
Fancygrid is currently in the proess of being refactored. Please be patient, there will definitely be a new release.
A new version of FancyGrid has been just released.
You can find all related plugins here:
https://www.ruby-toolbox.com/categories/Table_Builders
So there are several other plugins:
Tabletastic
TableForCollection
Tableasy
I'm trying to add tagging to my rails app - I'd rather not use a plugin/gem for this though.
My needs are pretty simple:
Users can add multiple tags to a single item, they can search for items by those tags, and they can see a page which lists all the tags they've used before.
What I'm wondering is, whats the best way to go about this? An array/hash in the model being tagged? A join table?
Any suggestions would be highly appreciated.
I would use a join table between the tags and the taggableItems. Then with a before_create you could check if the tag's are already in the system and create them if they aren't in the system. Next you could use searchlogic (i think there is a rails 3 branch on github) for easy tag/taggableItems searching. And it would be nice to give the user some feedback of the available tags with some autocompletion or a short list of most used tags but that is up to you/the design.
Maybe this helps you: Best Rails Tagging Plugin/Gem
What's the standard/best option out there for this kind of version control? The main thing I'm looking for is to track what user edited a record.
I've seen these so far and am wondering what your take is:
PaperTrail
ActsAsAudited
VestalVersions
The plugins you mentioned all seem to take the same approach, and seem to be somewhat similar in approach: use a seperate table to store the old versions.
None of them seem to be really rails3-ready (looking at the generators), but PaperTrail reportedly should work with rails3, and has the most recent commit.
You could also look at the ruby-toolbox user-stamping and versioning. There you can see which project has the most "traction", which has the most recent commits. Which sometimes can help to make a choice between similar options.
For stamping user_ids onto rows there is the the userstamp plugin
http://github.com/delynn/userstamp
EDIT:
Based on the requirement mentioned in your comment, I would recommend act_as_audited
http://github.com/collectiveidea/acts_as_audited
We are using it successfully for a very large application.
Peer
I think PaperTrail is what you need to solve this problem.
With PaperTrail you can track and see all changes ,to any model, with user id of who made the changes.
It is currently the best maintained project of the three you linked
HI #viatropos I thought that these two links might prove to be helpful
http://api.rubyonrails.org/classes/ActiveRecord/Observer.html
http://www.robbyonrails.com/articles/2007/04/27/observers-big-and-small
i am trying to get my head around the best way to develop an app in ruby on rails
i have a ducument creation system that for each document has multiple associations ie text docs, images, optional accessories etc. I have created this system now to do CRUD.
The next thing i want to do is have each document able to be translated into multiple languages and each document need to be versionized and audited with whats changed when and who dun it etc. Also i need to be able to clone a document for another user so he can then edit it for himself and with all above version and audit features.
I have looked at Globalize2, acts_as_audited, acts_as_versioned, paper_trail and deep_clone and sort of need abit of each !
Please can anyone help me with how or what is the best method of develping this app ? Is there better more suited plugins to use ? can these be used with each other ? and what would be the best process to set this up ?
any help would be most appreciated.
thanks
Rick
thanks askegg for your reply
the thing is acts_as_version does not include your models relations and i need to version each document model along with the children asscociated models ?
So basically if i dont use Globalize my transplated documents will just be other versions but in a different language. Is that correct ? I thought that is what Globalize does ?
thanks alot
rick
It seems you have a grasp of the basic structure you want and have investigated some alternatives.
First pass of my reading: You have a Document model, probably with a polymorphic association to an Asset model. Come to think of it, a Document is just a type of Asset, so one could inherit from the other - perhaps Single Table Inheritance.
From here, add acts_as_versioned to deal with ....well, versioning. This should also be able to give you the differences between various versions, just ensure you record the user_id along with the change.
I am not sure Globalise or i18n will help you here, as they are more geared to translating the web site itself with reasonably static content, not highly dynamic documents such as you're dealing with. I would leave translations to the users and use i18n to present different translations of the web site itself.
Cloning a document should not be too difficult - just create a new Document and populate the information in it. You will probably need a cloned_from_id field and build a self referential has_many in the model.
Well, they are the thoughts off the top of my head.
I was thinking you might treat each image, document, pdf, whatever as separate assets each with their own versions - operating independently of any other. If you need to clone a document and it's children, then you would need to iterate over the children and clone them as well - and their children's children. etc.
Globalise (or any other translation platform) is only really good for set/simple statements. Due to syntax and grammatical issues I would not expect it to be able achieve good translations between languages. Humans are great at that.
It occurs to me that you might want to think about using Git as a document store. This gives you full document versioning with tracking changes. See this presentation for some ideas. Don't worry about all the tech details - just think what it can do for you. The good stuff start about 15 minutes in. The Grit Ruby library can be found here.