Thanks to
http://justbarebones.blogspot.com/2007/12/linkto-helper-popup-option-and-ie.html
link_to "View Image", { :action => "view" }, :popup => ['new_window_name', 'height=300,width=600']
Thanks to
http://justbarebones.blogspot.com/2007/12/linkto-helper-popup-option-and-ie.html
link_to "View Image", { :action => "view" }, :popup => ['new_window_name', 'height=300,width=600']
<% remote_function :url => {:action => 'show_something'} %>
<% collection_select(:widget, :categories_id, Category.find(:all,
rder => "name"), :id, :name, {:prompt => "-Select a category"}, :id => 'id_selected') %>
<% observe_field 'id_selected', :url => {:action => 'show_something'}, :with => 'id' %>
I was working with an iFrame and trying to refresh the parent window when I found Responds to Parent. The first link is the plugin created by Sean Treadway and the second link is a neat tutorial by Khamsouk Souvanlasy.
Special thanks goes to Bill Garr of thinkabout.com who figured this one out. Hope he doesn’t mind I share it with the rest of the Rails community.
in /vendor/plugins/active_scaffold
* /javascripts/activescaffold.js
1. in ActiveScaffold.ActionLink.Abstract.prototype definition (~ line 220)
onComplete: function(request) {
this.loading_indicator.style.visibility = 'hidden';
init_tinyMCE();
}.bind(this)
2. in /views/_update_form.rhtml
url_options,
:before => "update_from_tinyMCE(this);",
:after => "$('#{loading_indicator_id(:action => :update, :id => params[:id])}').style.visibility = 'visible'; Form.disable('#{element_form_id(:action => :update)}');",
:complete => "$('#{loading_indicator_id(:action => :update, :id => params[:id])}').style.visibility = 'hidden'; Form.enable('#{element_form_id(:action => :update)}');",
:failure => "ActiveScaffold.report_500_response('#{active_scaffold_id}')",
:html => {
:href => url_for(url_options),
:id => element_form_id(:action => :update),
:class => 'update',
:method => :put
} %>
3. in your application.js (or any other .js that will be loaded)
function init_tinyMCE(){
if (!tinyMCE) return;
tinyMCE.isLoaded = false;
tinyMCE.onLoad();
}
function update_from_tinyMCE(form){
if (!tinyMCE || !form) return;
tinyMCE.triggerSave();
}
4. finally, you have to override the field display of every field that gets modified by tinyMCE. All you have to do is to change the default cleanup function, h(), to sanitize(), like so:
def body_column(record)
sanitize(record.body)
end
5. Restart Rails
I was getting an infinite loop with error “too much recursion” when I was using Rails auto_complete and Prototype 1.6.x. Apparently this version isn’t compatible with the version of scriptaculus that is installed with Rails. I went back to prototype 1.5.0 and it worked with no problems.
script/plugin install auto_complete
To add in multiple columns to your collection_select drop-down, create a method in your Model to concatenate:
Model:
def last_name_and_fullname
"#{last_name}, #{full_name}"
end
View:
<%= collection_select :record, :individual_id, Individual.find(:all,
rder => "last_name"), :id, :last_name_and_fullname, {:include_blank => true} %>
Was getting an odd error this morning:
compile error vendor/rails/activerecord/lib/active_record/base.rb:1359: syntax error Object::0
Turned out one of my columns had the name “type”. Not a good thing.
I tried out attachment_fu with Mike Clark’s tutorial and so far so good. This tutorial walks through the process of uploading and saving attachments i.e. images and resizing them into thumbnails. There are so many shady RoR tutorials out there so its refreshing to have Mike Clark explain in a easy going non-technical way. His approach is let Rails do the work for you and I couldn’t agree more.
Mike offers three image processor choices and I tried ImageScience and Minimagick. RMagick was skipped for no particular reason other than it was bigger than what I needed. I tried Minimagick first and I couldn’t get it working at all. Finally I tried ImageScience and with some help I was able to get it working.

Borrowed from Toronto Ruby on Rails pub night.