Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “ruby

Getting ActiveAdmin to Play Nice with Will_Paginate

My app was already using will_paginate extensively and I didn’t feel like changing it all to the Kaminari which ActiveAdmin uses for pagination.

However, somehow I was able to get it to work by thumbing through this ActiveAdmin issue.  I created the initializer suggested by kml with this code:

Kaminari.configure do |config| 
 config.page_method_name = :bonzo # :) 
end

However, when I implemented it, the code recommended for config/initializers/active_admin.rb caused me errors so I removed it.  You may find that you need this code.

Advertisements

Allowing HTML Tags in Form Fields

I wanted to allow my users to be able to include html tags in things they posted.  Originally, I was thinking that this was done as an option to the form field, but it actually is in the view where you display the user content.

In my case, I have this in the form:

<%= f.text_area :content %>

and where you want to display it, just add “.html_safe”, for example:

<%= article.content.html_safe %>


DevKit Missing

The first time I installed RoR, I used EngineYard’s wonderful RailsInstaller (railsinstaller.org), but for my upgrade, I wanted to go to 1.9.2, but they only had packages with 1.8.7 and 1.9.3.  So instead, I just downloaded 1.9.2 and installed it.

One thing I was missing with the DevKit (which I found out through an error message when I was installing my gems again).  So I installed it from http://rubyinstaller.org/downloads/ and then followed the directions on https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.  In the config.yml file generated, I just had to add where my new Ruby installation was (C:/Ruby192).


Pik

Most people who are not on Windows use RVM to manage their Ruby versions, but RVM doesn’t work for Windows.  Instead there’s a great tool called Pik that does the thing.  Pik allows you to switch between different Ruby versions you have on your PC.  I needed this once I went to 1.9.2.

The Github page for Pik is here: https://github.com/vertiginous/pik

The Github page didn’t include a lot of details though.  For more detailed instructions, I found this wonderful tutorial by Ben Hall:
http://blog.benhall.me.uk/2010/08/installing-rails-30-ruby-192-and-pik-on.html