Very often on Habré I meet topics or comments of those who like to reinvent the wheel. The arguments are the same as always:
1. so it is safer
2. too lazy to dig into someone else's code,
3. self-actualize.
Someone does not find a framework suitable for his needs, he writes his own and rivets business cards on it. And someone claims that Smarti weighs a lot of pain, tries to rewrite it, understands that he will not master it, and declares that it is unnecessary.
For those who save their time and use in the development of Ruby on Rails, I want to list a few plug-ins that can be useful in many projects.
1.
EditorsThere are two applicants
TimyMCE and
FCK . For both, there are plugins that simplify their integration into the RoR application.
')
We look.
wiki.rubyonrails.org/rails/pages/HowToUseTinyMCE and
www.underpantsgnome.com/projects/fckeditor-on-railsThe plugin for TinyMCE is better lit, but does not include downloading files (images) to
server. Find a ready-made solution did not work, found only examples of how to implement it. But not for
In addition, I use someone else's plugin to add something significant, because I looked for information about FCK. Here things are better. The plugin includes the controller required to download and view files on the server. Since for the rest both editors are similar, I chose FCK.
2.
HTML outputYou can use the standard h () helper, but it just escapes all the characters and HTML tags. To output formatted HTML text, I use the
WhiteList plugin, which filters out all unsafe tags.
weblog.techno-weenie.net/2006/9/3/white-listing-plugin-for-railsIt's simple: <% = white_list (@ article.body)%>
3. Again, back to
uploading files to the server . Zdes help plugin
attachment_fuclarkware.com/cgi/blosxom/2007/02/24It allows you to store data in the database or in the file system, checks downloaded files, can
process images.
class Photo <ActiveRecord :: Base
has_attachment: content_type =>: image,
: storage =>: file_system,
: min_size => 0.bytes,
: max_size => 500.kilobytes,
: resize_to => '700x500>',
: thumbnails => {: thumb => '200x200>'},
: processor =>: Rmagick
validates_as_attachment
end
4.
Error messages . If some field of the model fails validation, the rails will generate a message like Username is required, indicating the field name at the beginning of the sentence. When you try to set your own error messages, this behavior may not be convenient. I want to display something like “Enter your username correctly.” This can be done using the
Custom Error Message plugin.
wiki.rubyonrails.org/rails/pages/Custom+Error+MessageEnter the symbol "^" at the beginning of your error message and the field name will not be automatically added to it.
Compare
validates_acceptance_of: accepted_terms,: message => 'Please accept the terms of service', which will generate "Accepted terms Please accept the terms of service" and
validates_acceptance_of: accepted_terms,: message => '^ Please accept the terms of service'
5.
Captcha . Everything is simple. Generate captcha and check for validity allows the plugin
SimpleCaptcha .
expressica.com/simple_captchaDisplay captcha <% = show_simple_captcha%>.
Check
class User <ActiveRecord :: Base
apply_simple_captcha
end
user .valid_with_captcha? or
user .save_with_captcha
6.
Paginated output . The
WillPaginate plugin extends ActiveRecord by adding the paginate method,
which is almost identical to the standard find, and also adds a simple will_paginate helper to the templates. Very convenient and flexible plugin.
github.com/mislav/will_paginate/wikis@topics = Topic.paginate (: page => params [: page],: per_page => Topic.per_page,: order => 'created_at')
7.
Registration, login, logout. The
Acts_as_authenticated plugin
will generate the controller, model and
page templates required for registration and authentication in the application. The generated code is easy to customize.
wiki.rubyonrails.com/rails/pages/Acts_as_authenticated8.
Compress javaquipt and css. The
AssetPackager plugin in development mode loads all js and css files one by one, in production mode it uses their compressed versions into one file.
synthesis.sbecker.net/pages/asset_packagerPS All plugins are easy to install and use. Requires a minimum of reading and coding.