Its all about Ruby On Rails
Posts tagged ruby
Edge Rails: Now define your plugin’s routes in plugin’s config/routes.rb
Nov 28th
If you wrote/writing a rails plugin that need to have an entry in rails routing, you need not to ask your plugin users to make that entry in RAILS_ROOT/config/routes.rb manually any more. In the latest version of rails you can add your custum routes in your plugin config/routes.rb file. Rails will automatically load those routes.
WebByNode: A New Hosting Service Launching Soon
Nov 9th
Guys, I received a mail today that there will be a new hosting service launching soon. They said that it makes easier to deploy your applications. Whether its Ruby on Rails, Django, LAMP or your choice of Linux Distribution, its a ready-to-go solution. For more information please visit http://www.webbynode.com/
I am signing up there as a beta tester. Lets see how webby-node can help rails community by its services.
Ruby Funday: A Day full of Ruby fun event in India
Nov 4th
Monday, Tuesday, Wednesday, Thursday, Friday, Funday and Sunday.
Surprised, This is not a typo. Saturday is now converted to Funday. How??? Why??? When???
Geekeerie has started organizing new kind of events in India. One of those kinds of event is Ruby Funday. Which is a full day pure geek ruby event. Where geeks will show their code, tricks and funde .
The first Ruby Funday is scheduled for 22, Nov 2008 at Noida, India. For more details please visit their site(beta).
Capistrano: uploading / downloading directory to / from remote server via SCP or sftp
Oct 25th
Hey I found two interesting functions while going through capistrano’s files. There are two functions named “upload” and “download”, which can be used to download and upload directories from / to remote server using scp.
Examples:
upload(“LOCAL_DIR_PATH”, “REMOTE_PATH”, :via=> :scp, :recursive => true)
download(“REMOTE_PATH”, “LOCAL_DIR_PATH”, :via=> :scp, :recursive => true)
You can also use :sftp.
Unfortunately it is not much documented .
Configuring TinyMCE SpellChecker with rails application
Aug 8th
Last month I spent much time while configuring tinymce’s spellchecker with my rails application. But finally I got it working and thought I could be a good post. To configure this I took some help form gusto’s blog and google (as usual). So, Lets do it now without spending more time.
First of all create a rails app and install tinyMCE rails plugin:
1) rails tinymce
2) script/plugin install git://github.com/kete/tiny_mce.git
3) rake tiny_mce:scripts:install
We will be using aspell utility to check spellings so install “aspell” first. You can do it by “apt-get install aspell” or “port install aspell”
Once it is done then add following two lines in your layout(application.html.erb):
1) <%= javascript_include_tiny_mce_if_used %>
2) <%= tiny_mce if using_tiny_mce? %>
Now consider that I have a Users controller and User model with a text field ‘about_me’, and I want to use tinymce with spellchecker for that field.
To convert about_me textarea(new user form) to tinyMCE, add following code to users controller:
uses_tiny_mce(:options => {
:theme => ‘advanced’,
:mode => “textareas”,
:height => 100,
:content_css => “/stylesheets/base.css”,
:remove_script_host => true,
:theme_advanced_toolbar_location => “top”,
:theme_advanced_toolbar_align => “left”,
:theme_advanced_buttons2 => %w{ spellchecker },
:editor_selector => ‘mceEditor’,
:plugins => %w{ contextmenu paste spellchecker}
},
nly => [:new])
**Please cross check that you have added(enabled) ‘spellchecker’ in :plugins and added spellchecker button(I have added it in :theme_advanced_buttons2).
Now if you go to new user form you will see that about_me text area is replaced by tinymce editor with spellchecker button.
Now, add two more lines for spellchecker in above tinymce editor configuration:
1) :spellchecker_languages => “+English=en” (english language)
2) :spellchecker_rpc_url => “/users/spellchecker” (rails url where spellchecking will be done)
So our final configuration will be look like:
uses_tiny_mce(:options => {
:theme => ‘advanced’,
:mode => “textareas”,
:height => 100,
:content_css => “/stylesheets/base.css”,
:remove_script_host => true,
:theme_advanced_toolbar_location => “top”,
:theme_advanced_toolbar_align => “left”,
:theme_advanced_buttons2 => %w{ spellchecker },
:editor_selector => ‘mceEditor’,
:spellchecker_rpc_url => “/users/spellchecker”,
:spellchecker_languages => “+English=en”,
:plugins => %w{ contextmenu paste spellchecker}
},
nly => [:new])
Now download Spelling.rb, save it as spelling.rb in your rails lib dir and change ASPELL_PATH at line 7 according to your aspell installation.
Once it is done include this module(“include Spelling”) in application.rb or you controlller (here in our case users controller).
Now, create an action in named spellchecker in you controller(‘users’):
def spellchecker
headers["Content-Type"] = “text/plain”
headers["charset"] = “utf-8″
suggestions = check_spelling(params[:params][1], params[:method], params[:params][0])
results = {“id” => nil, “result” => suggestions, ‘error’ => nil}
render :text => results.to_json
return
end
Now, Type some thing in tinymce editor and click on spellchecker button. It will highlight misspelled words.
And when you click on highlighted misspelled word it will show suggessions.
Enjoy